Docker has become a fundamental tool in modern DevOps workflows โ from local development to CI/CD pipelines and production deployments. If you’re working with Ubuntu and want to set up Docker properly, hereโs a clear, step-by-step guide to get you up and running with best practices in mind.
โ Why Docker in DevOps?
Docker allows teams to package applications and their dependencies into containers โ lightweight, portable units that can run anywhere. For DevOps, this means:
-
Consistent environments across dev, test & production
-
Simplified deployment and rollback
-
Faster onboarding for new developers
-
Seamless integration with CI/CD tools (e.g. GitLab CI, GitHub Actions, Jenkins)
๐ง Installing Docker on Ubuntu
Hereโs how to install the official Docker Engine on Ubuntu (20.04 or newer):
1. Update and install dependencies:
sudo apt updatesudo apt install ca-certificates curl gnupg lsb-release
2. Add Dockerโs official GPG key:
sudo mkdir -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
3. Set up the stable Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4. Install Docker Engine & CLI tools:
sudo apt updatesudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
5. Test your Docker installation:
sudo docker run hello-world
You should see a success message from the Docker daemon.
๐ Run Docker as non-root (optional but recommended)
By default, Docker requires sudo. To avoid this:
sudo usermod -aG docker $USERnewgrp docker
This adds your user to the docker group so you can run Docker without typing sudo.
This is common in development environments. In production, always run Docker securely and restrict access via group permissions and firewalls.
๐ ๏ธ DevOps Tip: Use Docker with CI/CD
Once Docker is installed, integrate it into your pipelines:
-
GitLab CI: Use the official Docker-in-Docker (
dind) image -
GitHub Actions: Use
docker/build-push-actionfor multi-arch builds -
Jenkins: Use the Docker plugin or build agents inside containers
๐ Final Thoughts
Docker on Ubuntu is quick to install but powerful in its impact. Whether you’re building microservices, automating deployments, or preparing for Kubernetes, Docker is a foundational DevOps skill โ and this setup gets you started the right way.