Skip to content

Instantly share code, notes, and snippets.

@dantheman213
Last active April 27, 2020 00:43
Show Gist options
  • Save dantheman213/6cf79a701a39859c0a2de395e21f45f2 to your computer and use it in GitHub Desktop.
Save dantheman213/6cf79a701a39859c0a2de395e21f45f2 to your computer and use it in GitHub Desktop.
Docker Cheat Sheet

Docker Cheat Sheet

Copy file from container to host

docker cp <containerId>:/file/path/within/container /host/path/target

Stop all running containers

docker stop $(docker ps -aq)

Check running processes inside Docker container

docker top <CONTAINER_ID>

Check CPU, memory, I/O, and other resources of a container

docker stats <CONTAINER_ID>

All containers in real-time

docker stats

View all stopped containers

docker ps --filter "status=exited"

Download Docker image and run it on-the-fly

docker run <IMAGE_ID>

Enter a running Docker container

docker exec -it <CONTAINER_ID> /bin/bash

Enter last running Docker container

docker exec -it $(docker ps | head -2 | tail -1 | awk {'print $1'}) /bin/bash

Reset Docker To New State

https://gist.github.com/dantheman213/d4329c15911b48ff44d4bce5de8a7067

Override Entrypoint

docker run --entrypoint "/bin/sh sleep infinity"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment