Docker Container
Containers are instances of Docker images that
can be run using the Docker run
command. The basic purpose of Docker is to run containers. Let’s discuss how to
work with containers.
Run a Container-
Running of containers is managed with the Docker
run command. To run a container in
an interactive mode, first launch the Docker container.
#sudo docker run –it
centos /bin/bash
Then hit Crtl+p and
you will return to your OS shell.
Listing of Containers-
One can list all of the containers on the machine via the docker ps command. This command is used
to return the currently running containers.
#docker ps
docker ps -a-
This command is used
to list all of the containers on the system
#docker ps -a
─a – It tells the docker ps command to list all of the containers on the system.
docker history-
With this command,
you can see all the commands that were run with an image via a container.
#docker history
ImageID
ImageID – This is the Image ID for
which you want to see all the commands that
were run against it.
docker top-
With
this command, you can see the top processes within a container.
#docker top
ContainerID
ContainerID – This is the Container ID for which you want to see the top
processes
docker stop-
This command is used to
stop a running container.
#docker stop
ContainerID
ContainerID – This is
the Container ID which needs to be stopped.
docker rm-
This command is used to
delete a container.
#docker rm
ContainerID
ContainerID – This is
the Container ID which needs to be removed.
Return Value
The output will give the ID of the removed
container.
docker stats-
This command is used
to provide the statistics of a running container.
#docker stats
ContainerID
ContainerID
– This is the Container ID
for which the stats need to be provided.
Return Value
The output will show the CPU and Memory
utilization of the Container.
docker attach-
This command is used
to attach to a running container.
#docker attach
ContainerID
Once you have
attached to the Docker container, you can run the above command to see the
process utilization in that Docker container.
docker pause
This command is used to
pause the processes in a running container.
#docker pause
ContainerID
docker unpause-
This command is used
to unpause the processes in a
running container.
#docker unpause
ContainerID
The Docker pause command is used to pause an existing Docker container
docker kill-
This command is used
to kill the processes in a running container.
#docker kill
ContainerID
Docker – Container
Lifecycle-
The following
illustration explains the entire lifecycle of a Docker container.
Initially, the Docker container will be in the
created state.
Then the Docker container goes into the
running state when the Docker run
command is used.
The Docker kill command is used to kill an existing Docker container.
The Docker stop command is used to pause an existing Docker container.
Thanks for providing the information
ReplyDeleteKubernetes Online Training
Docker Online Training