Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Docker on Ubuntu

This guide shows you how to install Docker on an Ubuntu server and run your first container. It needs root access, so it is for VPS and dedicated server users.

VPS and Cloud Servers1 min read9 steps

What is Docker?

Docker runs programs inside containers. A container is like a lunch box. It holds one program and everything that program needs. You can move it to another server and it works the same way.

An image is the recipe for a container. You download an image, then start a container from it.

Steps

  1. Log in to your server with SSH. SSH lets you type commands on a remote computer.
  2. Update the package list and install a few helper tools.
    apt update
    apt install -y ca-certificates curl
  3. Create a folder for the Docker signing key. The key proves the software really comes from Docker.
    install -m 0755 -d /etc/apt/keyrings
  4. Download the key.
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    chmod a+r /etc/apt/keyrings/docker.asc
  5. Add the Docker software source.
    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" | tee /etc/apt/sources.list.d/docker.list > /dev/null
    This tells Ubuntu where to find Docker.
  6. Refresh the package list again.
    apt update
  7. Install Docker.
    apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  8. Check that Docker is running.
    systemctl status docker
  9. Run a test container.
    docker run hello-world
    Docker downloads a tiny image and prints a welcome message.

Handy commands

  • docker ps lists running containers.
  • docker images lists downloaded images.
  • docker stop NAME stops a container.
Tip: To use Docker without typing sudo, add your normal user to the docker group with usermod -aG docker USERNAME. Then log out and log in again. Only give this to people you trust, because it gives strong power over the server.

Quick recap

  • Docker runs programs in containers.
  • Add the Docker software source, then install with apt.
  • Test with docker run hello-world.
  • Use docker ps to see what is running.