# 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

```bash
sudo su
```

## Installing Docker

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

```bash
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

```bash
docker --version
```

which gave me the output of

```bash
Docker version 23.0.1, build a5ee5b1
```

## Installing docker-compose

The easiest way to install docker-compose is with

```bash
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

```bash
docker-compose --version
```

which should give an output similar to

```bash
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.
