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".


What is Dockerization and Docker images or template ?


DOCKERIZATION
Packaging (app + dependencies) and running an application within Docker container
It provides abstraction over the underlying OS services.
Dockerization is less resource-intensive than VM.





Applications shares the Linux Kernel with the OS running the host machine. 


DOCKER IMAGES
Docker containers are able to run applications inside containers and container works on templated images.

Docker images is a base of containers and based on UFS (Union File Sytem) of linux.

Images can be local or taken from central repository.

Templates are lightweight and its several versions can be managed.