Lesson 03/8 minutes/1 graded
Install Docker
Docker Engine on Fedora, Docker Desktop on Mac and Windows, and how to stop typing sudo before every command.
From here on you need Docker on your machine, because everything after this lesson is something you type and watch happen.
Install pages change as versions change, so treat the commands below as what worked for me and check the official install guide for your system before you start.
What you are installing
Two pieces matter. The Docker Engine is the service that does the actual work, and it runs in the background. The Docker CLI is the client you type commands into, and it talks to that service.
On Mac and Windows you install Docker Desktop, which brings the engine, the CLI and a graphical window for clicking through your containers. Docker Desktop is free for personal use and for companies with fewer than 250 employees and less than $10 million in annual revenue, per Docker's licence terms. Above that it needs a paid subscription.
On Linux you do not need Desktop. The engine runs natively, so you install it and the CLI, and that is enough.
Fedora, which is what I use
Add Docker's repository, then install:
sudo dnf config-manager addrepo --from-repofile https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Installing does not start it. Turn the service on and have it come back after a reboot:
sudo systemctl enable --now docker
Now run your first container to prove the whole chain works:
sudo docker run hello-world
You will see Docker say it could not find the image locally, pull it, and print a paragraph that starts with "Hello from Docker!". That paragraph is the image running, which means the engine, the pull and the container all worked.
Getting rid of that sudo
Typing sudo before every command gets old in about five minutes. Add yourself
to the docker group:
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world
Mac and Windows, briefly
Download Docker Desktop from Docker's install page and run the installer. On a Mac you drag it into Applications. On Windows the installer asks which backend you want, and WSL 2 is the default and the one to take.
Then open the app, wait for it to say it is running, and check the same thing I
did above with docker run hello-world in a terminal.
Prove it is working
Ask Docker what containers are running. On a fresh install the answer is none, and an empty table is the correct output here.
You will see a header row and nothing under it. That is exactly what we want at this point. Next we fill it.