0% found this document useful (0 votes)
210 views

Docker Commands

This document provides a cheat sheet of common Docker commands organized into sections on container basics, networks, files, updates, global info, and help. It lists commands for running, stopping, starting, restarting, and killing containers, as well as for listing containers and images, removing containers and images, and mapping ports. The document also summarizes commands for importing and exporting containers and images, copying files between the host and containers, viewing logs and resources usage, and updating containers and images.

Uploaded by

Bilal Sardar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views

Docker Commands

This document provides a cheat sheet of common Docker commands organized into sections on container basics, networks, files, updates, global info, and help. It lists commands for running, stopping, starting, restarting, and killing containers, as well as for listing containers and images, removing containers and images, and mapping ports. The document also summarizes commands for importing and exporting containers and images, copying files between the host and containers, viewing logs and resources usage, and updating containers and images.

Uploaded by

Bilal Sardar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Docker commands Cheat Sheet

by tobix10 via cheatography.com/27469/cs/7962/

Stored containers & images Container basics

List running containers docker ps Run in a new named docker run -it --name cont_name #image

List all containers docker ps -a container #command

Run as a daemon docker run -d #image #command


List images docker images [--tree]
Start container docker start -i #container
Remove container docker rm #container
Stop container docker stop #container
Remove image docker rmi #image
Restart container docker restart #container
Remove all containers docker rm `docker ps --no-trunc -aq`

Remove all images docker rmi `docker images -q` Kill container docker kill #container

Run a command docker exec -it #container #command


#container - name or id
#image - name #container - name or id
#image - name
Network #command - e.g /bin/bash -c 'Hello World' or script.py

Run with mapped ports docker run -d -p local_​por​t:c​ont​ain​er_port


Attach​/detach
#image #command

Show corres​ponding docker port #container contai​ner​_port Attach #1 docker attach #container

local port Attach #2 docker start -a

Attach #3 docker exec -it #container bash


Files
Detach CTRL-P + CTRL+Q
Map local docker run -it --name #container -v
Detach shortcut works in intera​ctive mode (run -i)
directory /src_p​ath​:/d​ock​er_path #image #command
Run container in detached mode: run -itd
Copy from/to docker cp #container src_pa​th:​des​t_path
docker Logs & info

Read container stdout docker logs [-f] #container


Updates
Show running processes docker top #container
Update image docker commit -m 'desc' -a 'author' #container
#image​:ne​w_tag Show container config​uration docker inspect #container

Add tag to image docker tag #container #image:tag Show resources usage docker stats #container

Rename container docker rename old_name new_name Show changes in filesystem docker diff #container

Show image history docker history #image


Update container docker update [options] #container
config​uration Show container events docker events

Read about config​uration options in help


Import & Export

Global info Export container to tar docker export -o file.tar #container

System​-wide info docker info Import container docker import file.tar

Version info docker version Export image to tar docker save -o file.tar #image​[:tag]

Import image docker load -i file.tar

Help

Command help docker #command --help

#command - name e.g attach, ps

By tobix10 Published 20th April, 2016. Sponsored by Readability-Score.com


cheatography.com/tobix10/ Last updated 20th April, 2016. Measure your website readability!
Page 1 of 1. https://readability-score.com

You might also like