Since Docker runs natively on Linux, it is usually much easier to install than on Mac or Windows machines. There are, however some quirks and details to be aware of. We cover couple of those in the following blog post.

What is the easiest way to get Docker on Ubuntu?

Docker is available in apt repos, and is thus fairly easy to install on Ubuntu. However, if you use apt for the installation, you won’t get docker-compose. Now, docker-compose is very valuable, especially for local development.

The quickest way to install a complete Docker tooolkit on Ubuntu 18.x (Bionic Beaver) or Ubuntu 20.x (Focal Fossa) is by using Snap:

> sudo snap install docker
> echo 'export PATH="/snap/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc

There is, however, an additional highly-recommended step that you probably want to perform. You see, by default Docker runs as root, and that is not very secure. You can make docker run as unprivileged user (e.g. your ssh user) by running following simple commands:

> sudo groupadd docker
> sudo usermod -aG docker $USER

You do have to logout after running these commands, for them to take effect. And by that, I don’t mean logging-out of just SSH connection, but actually logging your user out. To be safe, it may be a good idea to restart the server, if you can. Once you do that, you will be able to run all docker and docker-compose commands using your unpriviledged user, not: root.

And that’s pretty much all it takes to get docker toolchain on Ubuntu.