Monday, 31 December 2018

How to Deamonize and control a container in deamon mode ?


Deamonizing a container is spawning a docker container so that heavyweight processes are delegated to background.

RUNNING A DOCKER IN DEAMON MODE (BACKGROUND)
$ JOB=$(docker run -d unbuntu /bin/bash -c "while true; do echo Hello Docker; sleep 1; done")

$ docker ps
It will display list of all containers including latest launched container in background.

$ docker logs $JOB
It will show output of the running container.


CONTROLLING DOCKER DEAMON
$ docker stop | start | restart $JOB
It will stop container having name "JOB" and returns it's ID.

$ docker kill $JOB
It will kill the container having name "JOB" and returns it's ID.

$ docker stop $JOB
$ docker rm $JOB
It will stop and then remove the container from memory having name "JOB".


No comments:

Post a Comment

Note: only a member of this blog may post a comment.