Docker has revolutionized the way we deploy and manage applications. By leveraging containerization, Docker allows you to isolate applications and their dependencies into a single container, ensuring consistent environments across various systems. Ubuntu, being one of the most popular Linux distributions, is a great platform for Docker. In this comprehensive guide, we will walk you through the entire process of install Docker on Ubuntu, from system preparation to troubleshooting common issues.
Let’s dive in and get Docker running on your Ubuntu system!
Why Use Docker on Ubuntu?
Before we jump into the installation process, let’s first understand why Docker is so important and why Ubuntu is an excellent choice for running Docker.
Benefits of Using Docker
- Portability: Docker ensures that applications run the same, regardless of where they are deployed. Whether you’re developing on your local machine, deploying to the cloud, or testing in a staging environment, Docker containers behave consistently.
- Efficiency: Docker containers are lightweight compared to traditional virtual machines. They use fewer resources, which makes them more efficient and faster to spin up.
- Isolation: Docker provides isolated environments for applications, meaning each container has its dependencies and won’t interfere with others. This isolation improves security and stability.
- Scalability: Docker containers can be scaled quickly, allowing you to deploy multiple instances of an application in different environments.
- Ecosystem: Docker has a massive ecosystem, including Docker Hub, where you can pull pre-configured images, speeding up development and deployment.
Why Choose Ubuntu for Docker?
- Popularity: Ubuntu is one of the most widely used Linux distributions. It’s stable, secure, and actively maintained, making it a great choice for Docker.
- Compatibility: Docker supports Ubuntu and offers packages tailored to various versions of Ubuntu.
- Ease of Use: Ubuntu has a large community and ample documentation, which can help you resolve any issues you may encounter during installation.
Now that we know why Docker is essential and why Ubuntu is a great platform for it, let’s proceed with installing Docker on Ubuntu.
System Requirements for Install Docker on Ubuntu
Before installing Docker, ensure that your system meets the necessary requirements:
Supported Ubuntu Versions
Docker officially supports Ubuntu 18.04 (Bionic), 20.04 (Focal), and 22.04 (Jammy) for installation. Docker regularly updates its packages for these versions, ensuring better compatibility and performance.
Hardware Requirements
- RAM: At least 2GB for smooth Docker usage.
- Disk Space: Ensure you have adequate disk space as Docker stores images, containers, and volumes on your disk. Around 20GB of free space is recommended.
- CPU: A 64-bit CPU is required since Docker doesn’t support 32-bit systems for Ubuntu.
Software Requirements
- Ubuntu System: Make sure your Ubuntu system is up to date and has access to the internet.
- Root Privileges: You need to have the ability to install packages and execute commands with superuser privileges.
Once you’ve ensured that your system meets these requirements, you’re ready to proceed with the installation!

Step-by-Step Guide to Install Docker on Ubuntu
Step 1: Update Your Ubuntu System
Keeping your system updated is crucial to ensure that you have the latest security patches and software versions. To update your system, open a terminal and run the following commands:
bashCopysudo apt update
sudo apt upgrade
These commands will fetch the latest package information and upgrade any outdated packages on your system.
Step 2: Install Required Dependencies
Before installing Docker, you need to install some dependencies that are required for fetching and installing Docker packages from external repositories. Run the following command to install these dependencies:
bashCopysudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker’s Official GPG Key
Docker’s official GPG key is used to verify the authenticity of the Docker packages you download. Run the following command to add the GPG key:
bashCopycurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 4: Add Docker Repository to APT Sources
Once you’ve added the GPG key, you need to add the Docker repository to your system’s package source list. This will allow Ubuntu to fetch Docker packages directly from Docker’s official repository.
Run the following command to add the repository:
bashCopysudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
This command tells Ubuntu to use the official Docker repository for your Ubuntu version. The $(lsb_release -cs)
part will dynamically fetch your current Ubuntu version’s codename (e.g., bionic, focal).
Step 5: Install Docker Engine
Now that you’ve added the Docker repository, it’s time to install Docker. First, update your system’s package index with the following command:
bashCopysudo apt update
Then, install Docker by running the command:
bashCopysudo apt install docker-ce
This command installs Docker Community Edition (CE), which is free and open-source.
Step 6: Verify Docker Installation
To verify that Docker was installed successfully, you can check its version:
bashCopydocker --version
This will show the installed Docker version, for example:
CopyDocker version 20.10.7, build f0df350
To further verify the installation, you can run a test Docker container by using the hello-world
image. Run the following command:
bashCopysudo docker run hello-world
If Docker is correctly installed, you will see a “Hello from Docker!” message.
How to Manage Docker on Ubuntu?
Now that Docker is installed, you can start managing Docker on your Ubuntu system.
Start and Stop Docker Daemon
To start Docker:
bashCopysudo systemctl start docker
To stop Docker:
bashCopysudo systemctl stop docker
To restart Docker:
bashCopysudo systemctl restart docker
Enable Docker to Start on Boot
To make Docker start automatically when your system boots up, run the following command:
bashCopysudo systemctl enable docker
Check Docker Status
To check whether Docker is running, use:
bashCopysudo systemctl status docker
This will show you whether Docker is active and running.
Common Docker Commands to Get Started
Here are some basic Docker commands to help you get started.
Pull Docker Images
Docker images are the blueprints for creating Docker containers. You can pull Docker images from Docker Hub (the official repository) using the docker pull
command:
bashCopydocker pull ubuntu
This command will download the latest Ubuntu image from Docker Hub.
Run a Docker Container
Once you’ve pulled a Docker image, you can run a container based on that image:
bashCopydocker run -it ubuntu bash
This command runs an interactive (-it
) Ubuntu container and starts a Bash shell.
List Running Containers
To list all the running containers, use the following command:
bashCopydocker ps
Stop and Remove Containers
To stop a running container:
bashCopydocker stop <container_id>
To remove a stopped container:
bashCopydocker rm <container_id>
You can also remove all stopped containers at once by running:
bashCopydocker container prune
Troubleshooting Common Issues During Installation
Docker Daemon Not Running
If you receive an error like Cannot connect to the Docker Daemon
, it usually means that Docker isn’t running. To solve this issue, try restarting the Docker service:
bashCopysudo systemctl restart docker
Then, check its status:
bashCopysudo systemctl status docker
Permission Denied Errors
If you encounter “Permission Denied” errors when running Docker commands, you might not have the necessary permissions. You can add your user to the Docker group with the following command:
bashCopysudo usermod -aG docker $USER
After executing the command, log out and log back in for the changes to take effect.
Network or Proxy Issues
If you’re behind a proxy or experiencing network issues while installing Docker, you might need to configure Docker to work with your proxy settings. You can set the HTTP/HTTPS proxy in Docker by modifying Docker’s systemd configuration.
What’s Next After Installing Docker on Ubuntu?
Now that Docker is up and running, here are some things you can do next:
- Learn Docker CLI: Familiarize yourself with Docker’s powerful command-line interface. Learn to manage containers, images, networks, and volumes.
- Install Docker Compose: Docker Compose is a tool for defining and running multi-container Docker applications. It is essential for handling complex applications with multiple services.
- Explore Docker Hub: Docker Hub is a cloud-based registry where you can store and share your Docker images. Create an account to push your own images.
- Docker Security: Implement best practices like managing Docker group permissions, using
docker exec
cautiously, and regularly updating Docker to ensure security.
Conclusion
Congratulations! You’ve successfully install Docker on Ubuntu and are now ready to take advantage of the power of containerization. Docker allows you to develop, deploy, and manage applications in isolated environments, making your workflow more efficient and consistent. From here, you can explore more advanced Docker features, such as Docker Compose, container networking, and scaling applications.
As you dive deeper into Docker, remember to stay updated with the official Docker documentation and community forums to solve any challenges you encounter. Enjoy building, testing, and deploying containerized applications on your Ubuntu system!