Skip to content

Instantly share code, notes, and snippets.

@BekBrace
Last active May 4, 2023 06:30
Show Gist options
  • Save BekBrace/fb95801715cc3bd0787c98c136e8cf56 to your computer and use it in GitHub Desktop.
Save BekBrace/fb95801715cc3bd0787c98c136e8cf56 to your computer and use it in GitHub Desktop.
Docker Cheat Sheet
Container Management Commands
// docker create image [Create the container]
// docker run image [start the image]
// docker start container [start the container]
// docker stop container [graceful stop]
// docker kill container [kill container]
// docker restart container [stop + start]
// docker pause container [suspends container]
// docker unpause container [resume container]
// docker rm container [destroy container]
Inspecting container
// docker ps [list running containers]
// docker ps -a [list all containers]
// docker logs container [shows container output]
// docker top container [list the processes running inside the containers]
// docker diff container [shows the difference with the image]
// docker inspect container [shows low-level infos]
Interacting with the container
// docker attach container [attach to a running container]
// docker cp container:path hostpath\- [copy files fron container]
// docker cp hostpath\- container:path [copy files into container]
// docker export container [export the content of the container]
// docker exec container args... [run a command in an exsiting container(useful for debugging]
// docker wait container [wait until the container terminates and return the exit code]
// docker commit container image [commit a new docker image]
Image management commands
// docker images [list all local images]
// docker history image [show the image history
// docker inspect image [show low-level infos(in json format)]
// docker tag image tag [tag an image]
// docker commit container image [ create an image from a container]
// docker import url\- [tag] [create an image from a tarball]
// docker rmi image [delete images]
Image transfer commands
* Using the registry API
// docker pull repo [pull an image / repo from a registry]
// docker push repo [push an image / repo from a registry]
// docker search text [search an image on the official registry]
// docker login [login to a registry]
// docker logout [logout from a registry]
* Manual Transfer
// docker save repo [export an image/repo as a tarbal]
// docker load [load images from a tarball]
// docker-ssh [proposed script to transfer images between two daemons over ssh]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment