Docker Basic Commands

Check the docker version

docker version

List all the images present on the host .

docker images 

Only pull the docker image from docker hub.

docker pull image_name 

Run a container from image and list the output (CTRL+C) to exit.

docker run image_name 

Run a container from image in detach mode (-d as detached mode i.e in background )

docker run -d image_name 

Run a container from image in detach mode (-d as detached ), tag as if any version of image is available.

docker run -d image_name:tag

To remove the image from the host.

Note * : Remove all the dependent container before removing image.

docker rmi image_name 
docker rmi image_name:tag 

List all the running containers.

docker ps

List all the running containers and previously started or stopped containers.

docker ps -a 
docker ps -all

To stop the docker.

docker stop container_name|container id

To Kill the docker Process.

docker Kill container_name|container id 

To remove the docker container permanently.

docker rm docker_name|container id

To remove the docker container permanently (-f = force i.e if container is running we can force to remove container)

docker rm -f docker_name|container_id

Check the docker logs.

docker logs container_id

Execute a command inside the docker container.

docker exec docker_name|container_id bash 
docker exec -it docker_name|container_id bash
docker exec -i -t docker_name|container_id bash

Leave a Reply

Your email address will not be published.Required fields are marked *