Table of contents
No headings in the article.
docker ps -> lists all the running containers
The screenshot below shows that no containers are running
docker ps -a -> list all the containers irrespective of if they are running or not
3.docker run -> runs the container specified after the run if it exists on the docker host and if not downloads the container from docker hub and runs the container
4***.docker stop container_id*** -> stops a container if it is running
Run docker ps first to get container info such as container_id (d577cd8deddd) and then issue docker stop using the container_id as shown above. The output after stopping the container is the container id and that indicates the container has been stopped
5.docker rm container_id -> removes a stopped container from the local host
Run docker ps first to get container info such as container_id (d577cd8deddd) and then issue docker rm using the container_id as shown above. The output after removing the container is the container id and that indicates the container has been stopped
6.docker images -> lists all images available on the host
7.docker rmi image-id -> Removes the image-id specified from the host.
Note : All the containers using this image have to be stopped and deleted before the corresponding image can be removed
8.docker pull -> This command just pulls the container image from the docker hub if not present in the docker host but does not run the container
9.docker exec container-id command -> exec command allows us to execute a command inside a container.
In the screenshot below we are viewing the contents of /etc/hosts inside the running container specified via the container id using the cat command
10.docker run -d container-image -> The -d option with the run command runs the container for the image specified in the background
Author : Chandrasekar(Chan) Rajaram
https://www.linkedin.com/in/chan-rajaram-software-engineer/
#devops