Skip to main content

How to install Docker on Ubuntu VPS

Docker allows you to run applications in isolated containers. See how to install Docker Engine and Docker Compose on an Ubuntu VPS using the official repository.

Requirements

  • Ubuntu VPS with SSH access;
  • root user or sudo account;
  • updated system.
sudo apt update
sudo apt upgrade -y

1. Remove conflicting packages

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove -y $pkg; done

If no package is installed, the command will proceed normally.

2. Add official key

sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

3. Add the repository

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

4. Install Docker and Compose

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Check out the service:

sudo systemctl status docker

Press q to exit.

5. Test the installation

sudo docker run hello-world
docker --version
docker compose version

Current Compose uses docker compose, with space.

6. Optional: Run without sudo

sudo usermod -aG docker $USER

Log out of SSH and log in again.

Attention: members of the docker group have privileges equivalent to root.

Basic commands

docker ps
docker ps -a
docker images
docker logs NOME_DO_CONTAINER

Frequently asked questions

Does Docker work on any VPS?

The VPS must use a compatible architecture and enable the features required by Docker.

Is Docker Compose included?

Yes. The docker-compose-plugin package installs the docker compose command.

Do I need to open doors?

Only ports published by containers will receive external connections.

Where is the official documentation?

See Docker Engine installation on Ubuntu.


If you need help, open a ticket with Nice Hosting support.