Docker lets you package applications with everything they need to run. No more "it works on my machine" problems. This guide will get you running containers in no time.
What is Docker?
Docker is a platform for developing, shipping, and running applications in containers. Containers are lightweight and include everything needed to run the software.
Installing Docker
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
Running Your First Container
sudo docker run hello-world
Common Docker Commands
Run a Container
sudo docker run -d nginx
-d = detached (runs in background)
List Containers
sudo docker ps
sudo docker ps -a # all containers
Stop a Container
sudo docker stop container_id
Remove a Container
sudo docker rm container_id
List Images
sudo docker images
Working with Ports
sudo docker run -d -p 8080:80 nginx
Maps port 8080 on host to port 80 in container
Working with Volumes
sudo docker run -d -v /my/data:/data nginx
Mounts /my/data from host to /data in container
Docker Compose
sudo apt install docker-compose
Docker Compose lets you define multi-container applications in a single file.
You're now ready to start containerizing your applications!