Skip to content

Instantly share code, notes, and snippets.

@bcawrse
Last active March 7, 2020 02:23
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 bcawrse/97e7df22fc3fddc3c501f8ae7cb215ee to your computer and use it in GitHub Desktop.
Save bcawrse/97e7df22fc3fddc3c501f8ae7cb215ee to your computer and use it in GitHub Desktop.
Docker CLI clif-Notes

Docker CLI Refresher for when it's been awhile

Running things

Docker Compose!

docker-compose is super helpful to start docker stuff. Create a docker file, I've been having the best luck with version 3.1, and run docker-compose up. It's super nice.

docker-compose up -d runs docker-compose in detatched mode.

Side-notes

--rm
flag used when starting up a container which will automatically remove the container when it stops. Usefu for one-offs.

Viewing / Troubleshooting

To look at what's going on

docker ps -a OR docker container ls -a
docker network ls
docker volume ls

docker container ls --filter status=exited
List all exited containers. status can be any first word from the container ls -a command in the Status column.

Connect to a container that's already running
docker exec -it [containername] bash

Stopping / Removing

Quick stop ALL containers

docker container stop $(docker container ls -aq)

ALL OF IT

docker system prune
removes all stopped containers, all dangling images, and all unused networks.

docker system prune --volumes
ALSO prunes volumes

prune works on individual items too.
docker container prune docker network prune docker volume prune

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment