Installing Docker on a Server

This section explains how to install Docker and docker-compose on a server.

The guide starts from the assumption that you have set up a server, and you are connected to the server through ssh.

Root privileges are needed to install Docker, so before executing the commands below, make sure you are logged in as root, using

sudo su

Installing Docker

Docker provide an official script to install docker that works on most systems. The official script can be run with

curl -fsSL https://get.docker.com | bash

Once the command has finished and if it looks successful, you can check whether the Docker was installed correctly with

docker --version

which gave me the output of

Docker version 23.0.1, build a5ee5b1

Installing docker-compose

The easiest way to install docker-compose is with

curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose

If it looks like the command ran successfully, you can check the version with

docker-compose --version

which should give an output similar to

Docker Compose version v2.15.1

Awesome.

Summary

If the outputs of docker --version and docker-compose --version looked similar to the example output above (don't worry about exact version numbers), then your Docker installation should be set up correctly and ready to go.

Last updated