We need to carefully understand the life cycle of Docker containes. There are following images which depicts the the right phases of docker containers.
Phase of Docker Containers
- Create -> Destroy
- Create -> Start -> Stopped -> Destroy
- Create -> Start -> Pause -> Unpause
- Create -> Start -> Restart
Image flow of Simple Docker Container Lifecycle
Image flow of Detailed Docker Container Lifecycle
Image Source and Credits: http://docker-saigon.github.io/post/Docker-Internals/
Create container
$ docker create –name ubuntu-cont ubuntu
Run docker container
$ docker run -itd ubuntu
$ docker run -itd –name ubuntu-cont ubuntu
Pause container
$ docker pause <container-id/name>
Unpause container
$ docker unpause <container-id/name>
Start container
$ docker start <container-id/name>
Stop container
$ docker stop <container-id/name>
Restart container
$ docker restart <container-id/name>
Kill container
$ docker kill <container-id/name>
Destroy container
$ docker rm <container-id/name>