Installing Docker on Ubuntu 24.04 is a straightforward process that allows you to use container technology to develop, ship, and run applications. Docker is a popular tool among developers because it simplifies the process of managing application dependencies and ensures consistency across different environments. Whether you are a seasoned developer or a beginner, setting up Docker on your Ubuntu system can significantly enhance your workflow.
In this guide, we will walk you through the steps needed to install Docker on Ubuntu 24.04. We will start by updating your system, then install Docker, and finally, verify that Docker is working correctly on your machine.
Step 1: Update Your System
Before you install Docker, you need to update your system. Open your terminal and type:
sudo apt update
sudo apt upgrade
This will update your package lists and install any available upgrades.
Step 2: Install Docker on Ubuntu 24.04
To install Docker, add the Docker repository to your system. Run these commands in your terminal:
- Install required packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Configure the GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Set up the Docker PPA:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Update the package cache:
sudo apt update
- Install the Docker engine:
sudo apt install docker-ce container.io
Step 3: Start and Enable Docker
After installing Docker, start the Docker service and enable it to start on boot. Use these commands:
sudo systemctl start docker
sudo systemctl enable docker
Step 4: Verify Docker Installation
To check if Docker is installed correctly, run:
sudo docker --version
This command will display the installed Docker version.
![How to Install Docker on Ubuntu 24.04](https://tecadmin.net/wp-content/uploads/2024/07/docker-version-ubuntu2404.png)
Step 5: Add Current User to Docker Group
To run Docker commands without using sudo, add your current user to the Docker group. Execute the following command:
sudo usermod -aG docker $USER
Now, Apply the new group membership by logging out and back in, or by running:
newgroup docker
Step 6: Run Your First Docker Container
Now that Docker is installed, run a simple Docker container. Type the following command to run a test container:
docker run hello-world
This command downloads and runs a simple Docker container that prints “Hello from Docker!”
![How to Install Docker on Ubuntu 24.04](https://tecadmin.net/wp-content/uploads/2024/07/docker-helloworld-ubuntu2404.png)
Step 6: Frequently Used Docker Commands
Here are some basic Docker commands to help you get started:
- List Docker images:
sudo docker images
- List running containers:
sudo docker ps
- List all containers:
sudo docker ps -a
- Stop a running container:
sudo docker stop CONTAINER_ID
- Remove a container:
sudo docker rm CONTAINER_ID
- Remove an image:
sudo docker rmi IMAGE_ID
Conclusion
Congratulations! You have successfully installed Docker on Ubuntu 24.04 and run your first Docker container. Docker is a powerful tool that can simplify the process of managing and deploying applications. Keep exploring Docker commands and containers to become more comfortable with this tool.