Docker is kind of like running virtual machines, but in a more efficient method. Rather than having a virtual machine with their own kernel, services, and operating system, why not just re-use some of the resources of our host computer? So it does that, being very careful to prevent anything running on the container from breaking out.
Docker containers are defined in a “Dockerfile”, and its ubiquity makes it a very easy way of spinning up all sorts of services, inside of a Docker image (which can be copied!). Is 1 million more people watching YouTube tonight? Start up 100 containers or however many is needed to host all of their traffic.
Run these commands to check if docker is already installed:
sudo docker ps
sudo docker compose ls
And to check if it is working:
sudo docker ps
sudo docker compose ls
Make a new directory and go into it, and begin editing docker-compose.yml
.
# I'll be using a "docker-test" directory for this
mkdir docker-test
cd docker-test
nano docker-compose.yml
What do we put in it?
version: "3.8"
services:
whoami:
image: traefik/whoami:latest
container_name: whoami
restart: "no"
ports:
- "8080:80"