Docker command cheatsheet
To see all commands of docker
Write down docker on the command line. You will see all the commands of docker in the image below.
Get the status of the docker daemon
- Docker information:- docker info
Create a container without starting It
Creates container:- docker create [image name]
Docker run commands
Run container:- docker run [image name]
Run container with specified image version:- docker run [image name]:[version]
Docker run in background/detach mode image :- docker run -d [image name]
Docker naming container
- Docker naming container:- docker run -it --name [container name] [image name]
Docker renaming existing container
Docker renaming existing container :- docker rename [container name] [new container name]
Listing out running/stop containers, images, events of the container, history of images
List all running containers:- docker ps
List all running/stop containers:- docker ps -a
Lst out most recently created images:- docker images
List all images:- docker image ls
List real-time events from a container:- docker events [container name]
Check history of images :- docker history [option] [image]
Show running processes in a container:- docker top [CONTAINER]
- List all networks:- docker network ls
Docker start, stop, restart, pause, unpause, wait, kill, attach the container
Stop docker container :- docker stop [container name/id]
Start docker container :- docker start [container name/id]
Restart docker container :- docker restart [container name/id]
Pause docker container :- docker pause [container name/id]
Unpause docker container :- docker unpause [container name/id]
Wait docker container:- docker wait [container name/id]
Kill docker container :- docker kill [container name/id]
Attach docker container :- docker attach [container name/id]
Docker remove
Remove docker container :- docker rm [container name/id]
Remove docker image :- docker rmi [image name]
Remove all unused docker container:- docker container prune
Remove all unused docker images:- docker image prune
Remove all unused images as well as containers:- docker system prune
Remove one or more networks:- docker network rm [NETWORK]
Docker update
- Update the configuration of one or more containers:- docker update [CONTAINER]
Docker import
- Create an image from a tarball:- docker import [URL/FILE]
Docker commit
- Create an image from a container:- docker commit [CONTAINER] [NEW_IMAGE_NAME]
Docker load
- Load an image from a tar archive or stdin:- docker load [TAR_FILE/STDIN_FILE]
Docker pull
Pull docker image:- docker pull [image name]
Docker save
- Save an image to a tar archive, streamed to STDOUT with all parent layers, tags, and versions:- docker save [IMAGE] > [TAR_FILE]
Docker Mapping
Docker port mapping :- docker run -p [base ip:container ip] [image name]
Docker volume mapping :- docker run -v [base dir:container dir] [image name]
Show port (or specific) mapping for a container:- docker port [CONTAINER]
Docker run in interactive
Docker run in an interactive way:- docker run -it [image name]
Docker inspect
Docker find additional details of container :- docker inspect [container name/id]
- Show information on one or more networks:- docker network inspect [NETWORK]
- Show live resource usage statistics of containers:- docker stats [CONTAINER]
Docker logs
Docker check logs of container:- docker logs [container name/id]
- Connects a container to a network:- docker network connect [NETWORK] [CONTAINER]
- Disconnect a container from a network:- docker network disconnect [NETWORK] [CONTAINER]
- Detailed disk usage:- docker system df
- Space used by each container, image and volume:- docker system df -v
- Space used by running containers:- docker ps -s
- Filter only >= 1GB :- docker system df -v | grep GB
Comments
Post a Comment
Please give us your valuable feedback