Ubuntu Server 18.04 – Installing Docker

How to Create a Droplet with DigitalOcean

Installing Docker is very fast and easy, so much so that it barely constitutes its own section. In the last chapter, we had to install several packages in order to get a KVM virtualization server up and running as well as tweaking some configuration files. By comparison, installing Docker is effortless, as you only need to install the docker.io package:

sudo apt install docker.io
Docker is only supported on 64-bit versions of Ubuntu. The required package is available in 32-bit Ubuntu, but it’s not guaranteed to function properly. If you don’t recall which version of Ubuntu Server you installed, run the following command:
uname -m

You should receive the following output:
x86_64

Yes, that’s all there is to it. Installing Docker was definitely much easier than setting up KVM as we did in the previous chapter. Ubuntu includes Docker in its default repositories, so it’s only a matter of installing this one package and its dependencies. You’ll now have a new service running on your machine, simply titled docker. You can inspect it with the systemctl command, as with any other service:

systemctl status docker

You should see that the service is running, and enabled to start at boot. We also have the docker command available to us now, which allows us to manage our containers. By default, it does require root privileges so you’ll need to use sudo to use it. To make this easier, I recommend that you add your user account to the docker group before going any further. This will eliminate the need to use sudo every time you run a docker command. The following command will add your user account to the appropriate group:

sudo usermod -aG docker <yourusername>

After you log out and then log in again, you’ll be able to manage Docker much more easily.

You can verify your group membership by simply running the groups command with no options, which should now show you as a member of the docker group.

Well, that’s it. Docker is installed, your user account is a member of the docker group, so you’re good to go. Wow, that was easy!

Comments are closed.