1.

What are the basic actions performed on the docker container?

Answer»

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

  1. Pulls the image from Docker Hub if it’s not present in the RUNNING environment
  2. Creates the container.
  3. The file system is allocated and is MOUNTED on a read/write layer.
  4. A network interface is allocated that allows docker to talk to the host.
  5. Finds an available IP address from pool.
  6. Runs our application in our case “bash” shell.
  7. 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>

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>


Discussion

No Comment Found