October 21, 2021
Docker Commands Cheatsheet

Docker Commands Cheat Sheet

On this article we will present the Docker command line cheatsheet.

  1. Docker Command line for Container Lifecycle
  2. Docker Command line for Networking
  3. Docker Commands for Image Lifecycle
  4. Docker Commands For Start and Stop Container
  5. Docker Commands For Information

1. Docker command line for Container Lifecycle

Docker commandsDescirption
docker create [IMAGE]create a container without starting it
docker rename [CONTAINER_NAME] [NEW_CONTAINER_NAME]rename a container
docker run [IMAGE]create and start a container
docker run –rm[IMAGE]remove a container after it stops
docker run -td[IMAGE]start a container and keep it running
docker run -it [IMAGE]create, start the container, and run a command in it
docker run -t-rm [IMAGE]create,start the container, and run a command in it; after execting, the container is removed
docker rm [CONTAINER]delete a container if it is not running
docker update [CONTAINER]update the configuration of a container

2. Docker Command line for Networking

Docker CommandsDescription
docker network lslist network
docker network rm [NETWORK]remove one or more network
docker network inspectshow information on one or more networks
docker network connect [NETWORK] [CONTAINER]connect a container to a network
docker netwrok disconnect [NETWORK][CONTAINER]disconnect a container from a network

3. Docker Commands for Image Lifecycle

Docker CommandsDescription
docker build [URL]create an image from a Dockerfile
docker build -t [URL]build an image from a Dockerfile and tags it
docker pull [IMAGE]pull an image from a registry
docker push [IMAGE]push an image from a registry
docker import [URLFILE]create an image from a tarball
docker commit [CONTAINER] [NEW_IMANGE_NEWcrate an image from a container
docker rm [IMAGE]remove an image
docker load [TAR_FILE/STDIN_FILE]load an image from a tar archives as stdlin
docker save [IMAGE] >[TAR_FILE]save an image to a tar archives stream to astdout with all parent layers, tags, and version

4. Docker Commands For Start and Stop Container

Docker CommandsDescription
docker start [CONTAINER]start a container
docker stop [CONTAINER]stop a running container
docker restart [CONTAINER]stop a running container and start it up again
docker pause [CONTAINER]pause processes in a running container
docker unpause [CONTAINER]unpause processes in a container
docker wait [CONTAINER]block a container until other containers stop
docker kill [CONTAINER]kill a container by sending SIGKILL to a running container
docker attach [CONTAINER]attach local standard input, output, and erro streams to a running container

5. Docker Commands For Information

Docker CommandsDescription
docker pslist running containers
docker ps -alist running and stopped containers
docker logs [CONTAINER]list the logs from a running containers
docker inspect [OBJECT_NAME/ID]list low-level information on an object
docker events [CONTAINER]list real time events from a container
docker port [CONTAINER]show port (or spesific) mapping from a  container
docker top [CONTAINER]show running processes in a container
docker stats [CONTAINER]shwo live resource usage statistics of container
docker diff [CONTAINER]shwo changes to files (or directories) on a filesystem
docker image lsshow all locally stored images
docker history [IMAGE]show history of an image

Source : https://phoenixnap.com

Share this article via :

Leave a Reply

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