Add at command to docker

816 Views Asked by At

Hello i want to add At command to docker container. I am using linux alpine . I tried to use apk add at andapk add atd it is giving me the same error.

ERROR: unsatisfiable constraints: atd (missing): required by: world[atd]

Is there a way to fix that or can is there a way to use apt-get since at exists for apt-get

2

There are 2 best solutions below

0
ujlbu4 On

Looks like at just available as is: apk add at

this Dockerfile works fine for me:

FROM alpine:latest
RUN apk add at
CMD at --help

example run:

$ docker build -t at_command_line  -f Dockerfile .
$ docker run at_command_line:latest 
at: unrecognized option: -
Usage: at [-V] [-q x] [-f file] [-u username] [-mMlbv] timespec ...
       at [-V] [-q x] [-f file] [-u username] [-mMlbv] -t time
       at -c job ...
       atq [-V] [-q x]
       at [ -rd ] job ...
       atrm [-V] job ...
       batch
0
HyperActive On

I would just add to @ujlbu4's answer that you need to run the at daemon atd once your container is up and running or else the jobs will sit in the queue without getting executed.

Example Dockerfile:

FROM python:alpine
RUN apk add at
ENTRYPOINT ["atd"]

If you don't run atd you may see the following:

$ docker exec -it my_running_container /bin/sh
# echo "echo hi" | at now + 1 minutes
warning: commands will be executed using /bin/sh
job 6 at Mon Jun 21 18:11:00 2021
Can't open /var/run/atd.pid to signal atd. No atd running?