Skip to content

Instantly share code, notes, and snippets.

@Lucky-Loek
Last active October 6, 2021 09:54
Show Gist options
  • Save Lucky-Loek/b8d9b043deb4be2e3b829b5d69d07f34 to your computer and use it in GitHub Desktop.
Save Lucky-Loek/b8d9b043deb4be2e3b829b5d69d07f34 to your computer and use it in GitHub Desktop.
Docker workflow (also works in powershell)
# After creating a Dockerfile
docker build -t {tag-name} .
# Run one-off commands that are visible on host in current directory:
# docker run
# --rm [remove container after done]
# -it [with an interactive shell]
# -v ${pwd}:/opt [with volume of present working directory mounted in /opt]
# -w [with container working directory of /opt]
# {container} [the container name]
# {command} [the command to run in container]
docker run --rm -it -v ${pwd}:/opt -w /opt {container} {command}
# Remove all dangling and stopped containers
docker system prune
# Remove all images
docker rmi $(docker images -q)
# List all volumes
docker volume ls
# Remove unnecessary volumes
docker volume rm {name}
# Remove all unnecessary volumes
docker volume rm $(docker volume ls -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment