Google News
logo
Docker - Interview Questions
What are the basic actions performed on the docker container?
Basic actions on Docker containers are :
 
Create a docker container : Following command creates the docker container with the required images.
docker create --name <container-name> <image-name>
Run docker container : Following command helps  to execute the container
docker run -it -d --name <container-name> <image-name> bash
Main steps involved in the run command is
 
* Pulls the image from Docker Hub if it’s not present in the running environment
* Creates the container.
* The file system is allocated and is mounted on a read/write layer.
* A network interface is allocated that allows docker to talk to the host.
* Finds an available IP address from pool.
* Runs our application in our case “bash” shell.
* Captures application outputs

Pause container : Processes running inside the container is paused. Following command helps us to achieve this.
docker pause <container-id/name>
Container can’t be removed if in a paused state.
 
Unpause container : Unpause moves the container back to run the state. Below command helps us to do this.
docker unpause <container-id/name>
Start container : If container is in a stopped state, container is started.
docker start <container-id/name>
Stop container : Container with all its processes is stopped with below command.
docker stop <container-id/name>
To stop all the running Docker containers use the  below command
docker stop $(docker ps -a -q)
Restart container : Container along with its processes are restarted
docker restart <container-id/name>
Kill container : A container can be killed with below command
docker kill <container-id/name>
Destroy container : The entire container is discarded. It is preferred to do this when the container is in a stopped state rather than do it forcefully.
docker rm <container-id/name>
Advertisement