How to Install Docker on Ubuntu Server – Quick and Direct Guide
By Bruno Hoinacki

Installing Docker on Ubuntu Server is practically essential these days for anyone working with modern deployments, microservices, or who simply wants to run stacks like Nginx, Redis, PostgreSQL, Laravel, Node, etc., in isolated containers. This guide gets straight to the point: a step-by-step walkthrough to bail you out when your mind goes blank or when you are setting up a new machine for projects, and Forcoder is here to help. Save this article so you can come back whenever you need it.
📦 1. Update the system repositories
First, make sure your package list is up to date:
sudo apt update
If updates are available, you can install them with:
sudo apt upgrade -y
💡 Recomendado fazer isso sempre antes de instalar novos pacotes, especialmente em máquinas recém-criadas.
🐳 2. Installing Docker and Docker Compose
O Docker e o Docker Compose podem ser instalados diretamente dos repositórios padrão do Ubuntu (mantidos pela Canonical), o que já é suficiente para a maioria dos casos.
sudo apt install -y docker.io docker-compose
This will install:
- Docker Engine: to manage containers.
- Docker Compose: to orchestrate multi-container setups with
docker-compose.yml.
👤 3. Adding your user to the docker group
To avoid having to use sudo every time you run a Docker command:
sudo usermod -aG docker $USER
If it's a different user (not the current one), replace $USER with nomedeusuario.
⚠️ Important: after this command, log out and log back in (or restart your SSH session) for the group change to take effect.
💡 Quick alternative: If you don't want to end your session, run:
newgrp docker
This command reloads the user's groups in the current session, letting you use docker without sudo right away.
🔁 4. Enable Docker at startup
The service is usually enabled automatically, but it's worth making sure it starts with the system:
sudo systemctl enable docker
And to check the current status of the service:
sudo systemctl status docker
The output should show that the service is “active (running)”.
🧪 5. Quick test
To check that everything is working:
docker run hello-world
This test container prints a message confirming that everything is working correctly.
That's it! Docker and Docker Compose are installed and ready to host your favorite containers. Whether for local development, staging, or production, this simple stack speeds up the deployment of practically any modern application.
⚙️ Forcoder Tip: installing from Docker's official repository
If you always want the latest version of Docker, you can install it directly from the official repository (maintained by Docker Inc.). This is useful in production environments or when newer features are needed.


