Home · RSS · E-Mail · GitHub · GitLab · Twitter · Mastodon

Docker bits

first published:

» Post Updates

2023-03-01: Added Nixery as useful project.
2022-05-16: Added example for mounting the current directory into a docker container.
2021-06-12: Added --all --volumes --force args to docker system prune and removed separate commands for removing all images and volumes.

» Shell into a fresh container

Handy for some quick testing.

» Debian

1
docker run -it debian /bin/bash

» Alpine

1
docker run -it alpine /bin/ash

» Mount the current directory

1
docker run -it --volume $(pwd):/hostdir alpine /bin/ash

» Hostname of the host

When you are inside a docker container, you can use host.docker.internal for connections to the host machine.

» Stop all running containers

1
docker stop $(docker ps -q)

» Remove containers

» Remove all stopped containers

1
docker rm $(docker ps -aq)

» Remove all stopped and running containers

1
docker rm -f $(docker ps -aq)

» Docker System Prune

Clean up your host and free some space.

1
docker system prune --all --volumes --force



Home · RSS · E-Mail · GitHub · GitLab · Twitter · Mastodon