1

I'm trying to run an image of docker to be awake all the time with just one flag.

I'm trying without the tipical bash at the end or

while true; do sleep 1000; done 

in the ENTRYPOINT file because these solutions are using resources all the time.

For example, I don't want a command like this one:

docker run --rm -d --name dockerName dockerImage bash

I'm looking for something like:

docker run --rm --flagDockerAlwaysUp -d --name dockerName dockerImage
  • 2
    There's no such flag. To keep your container up, you will have to keep its process with `PID 1` running. A few good points about this are described here: [Docker container will automatically stop after “docker run -d”](https://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d). Maybe this `tail -f /dev/null` trick will fit your needs. – tgogos Apr 12 '19 at 08:55
  • If you are running this in Linux, you could create a systemd unit for the container. https://container-solutions.com/running-docker-containers-with-systemd/ You could have a long running command that never ends, but you would never know if your actual process is healthy and running. – Esteban Garcia Apr 12 '19 at 09:33
  • 1
    What's the container actually doing? When should it exit? How do you interact with it? – David Maze Apr 12 '19 at 09:54
  • @tgogos your trick should work @DavidMaze Is a hadoop, spark, hive server, I up the server with a configuration and expose some ports. It exit only with `docker stop DockerName` – Pablo López Gallego Apr 12 '19 at 10:13
  • @PabloLópezGallego I'm usually not really fond with the idea of having multiple services running in one container. But if you must for some reason, then you can use supervisord as your entrypoint. – Esteban Garcia Apr 12 '19 at 10:54

0 Answers0