Skip to main content

Get started with Docker

Sebastian

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

docker volume prune

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