Docker cheatsheet

sudo usermod -a -G docker $USER : adding current user to docker group

docker info :give information about docker

docker pull <image name> :Pull image from docker hub

docker images : shows all the available images

docker build . -t <image_name> :build image using dockerfile

docker image rm <image_name>:to remove a image.

docker image prune :to remove all unused images

CONTAINER

docker run -d <image name> : run a container in the background

docker run -p <host_port>:<container_port> <image_name> to run a container and map container port to host port

docker ps : show only running containers

docker ps -a: show all containers

docker logs <container name> : batch-retrieves logs present at the time of execution.

docker exec -it <container id> /bin/bash :open a shell inside running container

docker start/stop :to start/stop container

docker attach <container_id> : to go inside the container

docker rm <container_id>:to remove stopped container

exit :to exit from the container

DOCKER HUB

docker pull <image_name> :to pull image from docker hub

docker search <image_name> :to search image on docker hub

VOLUME

docker volume ps :to view all the existing volume

docker volume inspect <volume_name> :to get volume detail

docker volume rm <volume_name> :to remove volume

docker volume create <volume_name> :to create a volume

docker run -v <source>:<target> <image_name> : to create a volume

Hope you find it useful!!

~Sujata Kumari