In this article, We are going to cover Docker command cheat sheet in Image format , Docker compose commands cheat sheet and Docker commands cheat sheet pdf.
- Dockerfile Commands Cheat Sheet
- Dockerfile Cheat Sheet Free
- Dockerfile Cheat Sheet Example
- Docker Compose Command Cheat Sheet
- Dockerfile Cheat Sheet
- Docker Command Cheat Sheet
Table of Contents
Docker Lifecycle Commands
Given our affinity for Docker, we wanted to pass along some tips and best practices for using it at the command-line. To do that we’ve created a convenient Docker Commands Cheat Sheet to help improve your work flow. Windows Docker Cheat Sheet Raw. Windows-docker-cheat-sheat.md Build docker image PS cd path to Dockerfile PS docker build. View running processes.
The one-page guide to Dockerfile: usage, examples, links, snippets, and more.
Below are some commonly used Docker Basic commands you will use frequently.
1) docker – To check all available Docker Commands
2) docker version – To show Docker version
3) docker info – Displays system wide information
4) docker pull – To pull the docker Images from Docker Hub Repository
5) docker build – To Docker Image from Dockerfile
6) docker run – Run a container from a docker image.
7) docker commit – To commit a changes in container file OR create new Docker Image
8) docker ps – List all the running containers. Add the -a flag to list all the containers.
9) docker start – To start a docker container
10) docker stop– To stop a docker container
11) docker logs -To view Logs for a Docker Container
12) docker rename – To rename Docker Container
13) docker rm – To remove the Docker Container, stop it first and then remove it
#1. Docker Image Commands
Docker Image is a application template including binaries and libraries needed to run a Docker container.
Below are some commonly used Docker Image commands while working with Docker.
1) docker build – To build Docker Image from Dockerfile
2. docker pull – To pull Docker Image from Docker Hub Registry
3. docker tag – To add Tag to Docker Image
4. docker images – To list Docker Images
5. docker push – To push Docker Images to repository
6. docker history – To show history of Docker Image
7. docker inspect– To show complete information in JSON format
8. docker save – To save an existing Docker Image
9. docker import – Create Docker Image from Tarball
10. docker export – To export existing Docker container
11. docker load– To load Docker Image from file or archives
12. docker rmi– To remove docker images
#2. Docker Container Commands
1) docker start – To start a Docker container
2) docker stop – To stop a running docker container
3) docker restart – To restart docker container
4) docker pause – To pause a running container
5) docker unpause – To unpause a running container
6) docker run – Creates a docker container from docker image
7) docker ps – To list Docker containers
8) docker exec – To Access the shell of Docker Container
9) docker logs – To view logs of Docker container
10) docker rename – To rename Docker container
11) docker rm – To remove Docker container
12) docker inspect – Docker container info command
12) docker attach – Attach Terminal to Running container
12) docker kill – To stop and remove Docker containers
13) docker cp – To copy files or folders between a container and from local filesystem.
#3. Docker Compose Commands
Docker compose is used to run multiple containers in a single application.
Below are some commonly used docker compose command line you should know
1) docker-compose build – To build docker compose file
2) docker-compose up – To run docker compose file
3) docker-compose ls – To list docker images declared inside docker compose file
4) docker-compose start – To start containers which are already created using docker compose file
5) docker-compose run – To run one one of application inside docker-compose.yml
6) docker-compose rm – To remove docker containers from docker compose
7) docker-compose ps – To check docker container status from docker compose
#4. Docker Volume Commands
1) docker volume create – To create docker volume
2) docker volume inspect – To inspect docker volume
3) docker volume rm – To remove docker volume
#5. Docker Networking Commands
1) docker network create – To create docker network
2) docker network ls – To list docker networks
3) docker network inspect – To view network configuration details
#6. Docker Logs and Monitoring Commands
1) docker ps -a – To show running and stopped containers
2) docker logs – To show Docker container logs
3) docker events – To get all events of docker container
4) docker top – To show running process in docker container
5) docker stats – To check cpu, memory and network I/O usage
6) docker port – To show docker containers public ports
#7. Docker Prune Commands
Using Docker prune we can delete unused or dangling containers, Images , volumes and networks
To clean all resources which are dangling or not associated with any docker containers
docker system prune
To remove unused and stopped docker images
docker system prune -a
To remove Dangling Docker images
docker image prunedocker image prune -a
To remove all unused docker containers
docker container prune
To remove all unused docker volumes
docker volume prune
To remove all unused docker networks
docker network prune
Dockerfile Commands Cheat Sheet
We have covered Docker command cheat sheet.
Dockerfile Cheat Sheet Free
#8. Docker Hub Commands
To search docker image
docker search ubuntu
To pull image from docker hub
docker pull ubuntu
Push the Docker Image again
docker push fosstechnix/nodejsdocker
To logout from Docker Hub Registry
docker logout
Download Docker Command Cheat Sheet in Image Format by clicking Download Button.
Download Docker Commands Cheat Sheet PDF format
Click on below to Download Button to download docker commands cheat sheet pdf format.
Conclusion
In this article, We have covered Docker command cheat sheet in Image format , Docker compose commands cheat sheet and Docker commands cheat sheet pdf.
Related Articles
Docker Installation
Dockerfile Instructions
Docker Image
Docker Compose
Docker Commands
Docker Interview Questions and Answers for Freshers
0 Shares
IMAGES
show images on hostdocker images
get image ID by name
docker images –format=”{{.ID}}” myImageName
inspect imagedocker inspect image:version | jq
.
Remove
remove image by namedocker rmi reponame:tag
remove dangling imagesdocker image prune
remove all images that dont have a child container runningdocker image prune -a
remove ALL imagesdocker rmi $(docker images -qa)
————————————————————————————————————-
Build
build an image from Dockerfiledocker build -t user/image-name .
Dockerfile config:
FROM debian:layer #provide a base image
RUN apt-get update && apt-get install -y cowsay #run additional commands to build container
ENTRYPOINT /usr/bin/telnet
ADD /host_dir /target_dir #copy contents to container from the host
CMD 'echo' 'all done!' #cmd to execute once container is built
ENV PROXY_SERVER http://www.proxy.com #set env vars
EXPOSE 8250 #expose port from service inside container to outside
USER 125 #UID of user running the container
VOLUME ['/tmp'] #enable access from container to dir on the host machine
WORKDIR ~/dev #where CMD will execute from
COPY file.conf /etc/app/app.conf #copy from host to container
Dockerfile Cheat Sheet Example
————————————————————————————————————–
COMPOSE
SWARM
Docker Compose Command Cheat Sheet
CONTAINERS
Dockerfile Cheat Sheet
RUN/STOP
Docker Command Cheat Sheet
REMOVE