Skip to main content

Get started with Docker

Sebastian
Writer

docker

I just tried out Docker for a small project and now I get all the hype around it. While searching for good guides I stumbled upon this excellent tutorial by Prakhar Srivastav: A Docker Tutorial for Beginners. If you want a deeper understanding of Docker and how it works, and not only how to spin up a container and leave it running, I highly recommend reading it. He also go through the basics of writing your own Docker image which helped me a lot.

Documentation

Install

pacman -Syu docker docker-compose
systemctl start docker
systemctl enable docker
docker info

Usage

FunctionCommand
Pull imagedocker pull image
Remove imagedocker image rm image
List imagesdocker image ls
Run containerdocker run --name container options image
List containersdocker container ls
Stop containerdocker container stop container
Remove containerdocker container rm container
Remove inactive containersdocker container prune
Switch to container shelldocker exec -ti container /bin/sh
Exit container shellexit
Build imagedocker build --no-cache -t username/image:tag .
Delete stopped containers, networks, images and build cachedocker system prune -a
Delete dangling volumesdocker volume prune
Rename volumedocker volume create --name new_volume &&
docker run --rm -it -v old_volume:/from -v new_volume:/to alpine ash -c "cd /from ; cp -av . /to" &&
docker volume rm old_volume

Docker Compose update images

If you're using Docker compose and want to update the images to the latest versions you can run the following when in the same directroy as docker-compose.yaml

docker-compose up --force-recreate --build -d
docker image prune -f