Docker is an open-source platform for developing, testing, and running applications. Docker provides a way to package and run an application in a container. A container is an isolated environment which contains everything needed for an application to run.
This tutorial explains how to install Docker Community Edition (CE) on Ubuntu 24.04.
Install Docker CE
Download GPG key and add to a specified directory:
sudo wget -qO /etc/apt/keyrings/docker.asc https://download.docker.com/linux/ubuntu/gpg
Add the Docker CE repository:
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -sc) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Install the Docker CE:
sudo apt update
sudo apt install -y docker-ce
By default, root and user with sudo privileges can use Docker. During installation, a group docker
is created. So, if you want to allow using Docker for non-root users, you can add the user to the docker
group.
Add current user to docker
group:
sudo usermod -a -G docker $USER
To make changes to take effect, logout and login to your machine. After you're reconnected, check Docker version:
docker version
We can use the following command to determine if Docker service is running:
sudo service docker status
We can also stop, start and restart the Docker service:
sudo service docker stop
sudo service docker start
sudo service docker restart
Testing Docker CE
To test that Docker successfully installed, you can run the hello-world
image.
docker run hello-world
The command downloads a test image, runs it in a container, prints a message, and exits.
Uninstall Docker CE
If you decided to completely remove Docker CE and related dependencies, run the following command:
sudo apt purge --autoremove -y docker-ce
When it finished, remove the docker
group:
sudo groupdel docker
During installation, a network interface docker0
is installed. You can remove it with command:
sudo ip link delete docker0
Remove GPG key and repository:
sudo rm -rf /etc/apt/keyrings/docker.asc
sudo rm -rf /etc/apt/sources.list.d/docker.list
You can also remove Docker configuration, images, containers, and other related directories:
sudo rm -rf /etc/docker
sudo rm -rf /var/lib/docker
sudo rm -rf /run/docker
sudo rm -rf /var/run/docker.sock
sudo rm -rf /var/lib/containerd
sudo rm -rf /opt/containerd
The 1 Comment Found
Very concise,,,appreciate your help,Thanks
Leave a Comment
Cancel reply