Skip to content

Instantly share code, notes, and snippets.

@donrestarone
Last active December 15, 2020 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donrestarone/513077f8b35122480a7cbe2efe7a8b42 to your computer and use it in GitHub Desktop.
Save donrestarone/513077f8b35122480a7cbe2efe7a8b42 to your computer and use it in GitHub Desktop.
docker cheatsheet

docker cheatsheet

viewing available/running containers

docker ps shows running containers, amd docker container ls lists available containers

docker ps
docker container ls

viewing available images

docker ps shows running containers, amd docker container ls lists available containers

docker image ls

stopping and removing containers

after listing containers you can remove them by id or name

docker stop <container_id or name>
docker rm <container_id or name>
# for a deep clean you can run 
docker system prune

running a shell inside container

getting into the container's shell via the interactive shell (interactive TTY) can be done with:

docker container run -it ubuntu bash

port mapping for containers

the following command pulls the nginx image and exposes it on localhost:80

docker container run --publish 80:80 nginx

monitoring containers

we can use top, inspect or tail the logs

docker container run -d --name nginx --publish 80:80 nginx
docker top nginx
docker inspect nginx
docker container stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment