Houssein Zouari
Houssein Zouari

Reputation: 722

Add at command to docker

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

Upvotes: 0

Views: 1037

Answers (3)

Rafael Mori
Rafael Mori

Reputation: 949

Try this:

  1. On Dockerfile include: RUN apt-get update && apt-get install -yyq at
  2. Then insert $(which atd) (to manually starts the atd daemon) on CMD clause from Dockerfile. You an join that with any other command you're already running. I'm running this at my container's Dockerfile: CMD ["$(which atd) && bash /check_conf.sh"]
  3. Now check if daemon atd is running with: docker top container-name | grep atd on the host, you must see this (my output):

daemon 43550 33705 0 00:42 ? 00:00:00 /usr/sbin/atd

Then inside my "/check_conf.sh" file, i was able to run at command with success.

Note: This will not grantee the daemon runs always. You can adapt the solution for your environment. It's just a workaround that works for me on ubuntu-based or debian-based images (for my environment).

Hope it helps...

Upvotes: 0

HyperActive
HyperActive

Reputation: 1316

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?

Upvotes: 1

ujlbu4
ujlbu4

Reputation: 1138

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

Upvotes: 3

Related Questions