Skip to content

Money-back guarantee within 72 h, VPS and web

Install Docker and Docker Compose on a Linux VPS

Connect with SSH, run the official Docker install script, then test with hello-world.

Install Docker

  1. 1.Connect to your VPS with SSH.
  2. 2.Type curl -fsSL https://get.docker.com | sudo sh, then Enter. This is the official Docker install script: it detects the distribution and installs everything needed.
  3. 3.Wait until the command prompt comes back.
  4. 4.Test with sudo docker run hello-world. The message Hello from Docker! confirms that the install works.

Prefer to install Docker by hand, package by package? Follow the official Docker documentation.

Use Docker without sudo

  1. 1.Add your user to the docker group: sudo usermod -aG docker $USER.
  2. 2.Log out, then log back in over SSH.
  3. 3.Type docker ps. The command answers without sudo.

Being in the docker group is equivalent to having root rights on the VPS. Only add users you trust.

Use Docker Compose

Docker Compose is already installed with Docker, as a plugin. Type docker compose, with a space, not docker-compose.

  1. 1.Check the install: docker compose version.
  2. 2.Go to your project folder, the one that contains the compose.yaml file.
  3. 3.Start the containers in the background: docker compose up -d.
  4. 4.Check their status with docker compose ps, and their logs with docker compose logs -f (Ctrl+C to quit).
  5. 5.Stop them with docker compose down.

Run a first test site

  1. 1.Start a web server: docker run -d --name web -p 80:80 nginx.
  2. 2.In your browser, open http:// followed by the VPS IP address. The Welcome to nginx! page appears.
  3. 3.Remove the test: docker rm -f web.

Docker bypasses the ufw firewall for ports published with -p: a container published on port 80 stays reachable even if ufw blocks it. Only publish what has to be, or limit the port to the machine itself with -p 127.0.0.1:8080:80.

In this topic

View all 6 guides