0% found this document useful (0 votes)
47 views1 page

Docker Cli: Run A New Container Manage Containers Manage Images Info & Stats

This cheat sheet provides concise summaries of common Docker CLI commands for running containers, managing images, and getting container information. It lists commands for starting and stopping containers, pulling and pushing images to repositories, viewing logs and stats, copying files between containers and hosts, renaming containers, and more.

Uploaded by

sammy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

Docker Cli: Run A New Container Manage Containers Manage Images Info & Stats

This cheat sheet provides concise summaries of common Docker CLI commands for running containers, managing images, and getting container information. It lists commands for starting and stopping containers, pulling and pushing images to repositories, viewing logs and stats, copying files between containers and hosts, renaming containers, and more.

Uploaded by

sammy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CHEATSHEET FOR

DOCKER CLI
RUN A NEW CONTAINER MANAGE CONTAINERS MANAGE IMAGES INFO & STATS
Start a new Container from an Image Show a list of running containers Download an image Show the logs of a container
docker run IMAGE docker ps docker pull IMAGE[:TAG] docker logs CONTAINER
docker run nginx docker pull nginx docker logs web
Show a list of all containers
...and assign it a name docker ps -a Upload an image to a repository Show stats of running containers
docker run --name CONTAINER IMAGE docker push IMAGE docker stats
docker run --name web nginx Delete a container docker push myimage:1.0
docker rm CONTAINER Show processes of container
...and map a port docker rm web Delete an image docker top CONTAINER
docker run -p HOSTPORT:CONTAINERPORT IMAGE docker rmi IMAGE docker top web
docker run -p 8080:80 nginx Delete a running container
docker rm -f CONTAINER Show a list of all Images Show installed docker version
...and map all ports docker rm -f web docker images docker version
docker run -P IMAGE
docker run -P nginx Delete stopped containers Delete dangling images Get detailed info about an object
docker container prune docker image prune docker inspect NAME
...and start container in background docker inspect nginx
docker run -d IMAGE Stop a running container Delete all unused images
docker run -d nginx docker stop CONTAINER docker image prune -a Show all modified files in container
docker stop web docker diff CONTAINER
...and assign it a hostname Build an image from a Dockerfile docker diff web
docker run --hostname HOSTNAME IMAGE Start a stopped container docker build DIRECTORY
docker run --hostname srv nginx docker start CONTAINER docker build . Show mapped ports of a container
docker start web docker port CONTAINER
...and add a dns entry Tag an image docker port web
docker run --add-host HOSTNAME:IP IMAGE Copy a file from a container to the host docker tag IMAGE NEWIMAGE
docker cp CONTAINER:SOURCE TARGET docker tag ubuntu ubuntu:18.04
...and map a local directory into the container docker cp web:/index.html index.html
docker run -v HOSTDIR:TARGETDIR IMAGE Build and tag an image from a Dockerfile
docker run -v ~/:/usr/share/nginx/html nginx Copy a file from the host to a container docker build -t IMAGE DIRECTORY
docker cp TARGET CONTAINER:SOURCE docker build -t myimage .
...but change the entrypoint docker cp index.html web:/index.html
docker run -it --entrypoint EXECUTABLE IMAGE Save an image to .tar file
docker run -it --entrypoint bash nginx Start a shell inside a running container docker save IMAGE > FILE
docker exec -it CONTAINER EXECUTABLE docker save nginx > nginx.tar
docker exec -it web bash
Load an image from a .tar file
Rename a container docker load -i TARFILE
docker rename OLD_NAME NEW_NAME docker load -i nginx.tar
docker rename 096 web
Create an image out of container
docker commit CONTAINER
docker commit web

DOCKER CLI CHEATSHEET v1.0.1 by [email protected]

You might also like