Guides/Server Setup
Server Setup6 min read

How to Install Docker on Ubuntu (The Right Way)

Install Docker Engine on Ubuntu from the official Docker repository — not the outdated snap or apt package. This guide covers installation, post-install setup, and running your first container.

Remove Old Docker Versions

Remove any old Docker installations that may conflict: sudo apt remove docker docker-engine docker.io containerd runc. These are outdated packages from the Ubuntu apt repository. The official Docker Engine package is called docker-ce and must be installed from Docker's own apt repository.

Install Docker from the Official Repository

Add Docker's GPG key and repository: sudo apt update && sudo apt install -y ca-certificates curl — then add the keyring and repo as shown in the official Docker docs for Ubuntu. Then install: sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin. Start and enable: sudo systemctl enable --now docker.

Run Docker Without Sudo

By default Docker requires sudo. Add your user to the docker group: sudo usermod -aG docker $USER. Log out and back in (or run newgrp docker). Verify: docker run hello-world. Running Docker without sudo is standard practice on development machines. On production servers, consider keeping sudo requirement for an extra security layer.

Essential Docker Commands

docker ps — list running containers. docker ps -a — list all containers including stopped. docker images — list local images. docker pull nginx — download an image. docker run -d -p 80:80 nginx — run nginx in background on port 80. docker stop <id> — stop a container. docker rm <id> — remove a container. docker logs <id> — view container logs. docker exec -it <id> bash — open a shell inside a running container.

Verify Installation and Run Hello World

Run: docker run hello-world. Docker pulls the hello-world image from Docker Hub and runs it. You should see a "Hello from Docker!" message. This confirms Docker Engine, the Docker CLI, and network connectivity to Docker Hub are all working correctly. Then check the version: docker --version and docker compose version.

Need Help?

Want this done for you?

Our engineering team handles implementations like this every week. Get a free scoping call — we will tell you exactly what it takes and what it costs.

Book a free call

© 2026 NexWorldTech — Built for Global Dominance.