I was wondering if anyone knew if it is possible to know when a docker CMD is done executing?
I initially have tried putting an ENTRYPOINT command after the CMD but it runs immediately when you run the docker container.
Also, if this can only be done with docker-compose that would be fine as well if there is a way to know when the command: is finished?
The first two answers are indeed correct but don't directly answer your questions. Once the CMD
is finished the container will exit, but will still exist on your host until it's removed.
Assuming you started the docker run
or docker-compose up
with a -d
so that they run in the background (detached):
docker container ps
only shows running containers, so once it's exited then docker container ps -a
will show it.docker-compose ps
shows the status of all compose services, including stopped containers.