Docker is a compact virtualization that runs on top of the operating system, allowing users to design, run, and deploy applications encased in small containers. It is a collection of platform-as-a-service (PaaS) tools for launching and managing containers. Docker containers are used by developers to develop and deploy apps because they are isolated and lightweight.
Docker has transformed the software engineering business, changing not just how we deliver and deploy applications but also how engineers build-up application development environments on their workstations.
Linux containers are robust, scalable, and secure. A Docker container's processes are always insulated from the host system, avoiding manipulation from the outside.
In this tutorial, I will show you how to install, use, and remove Docker on an Ubuntu Linux system.
Note: Although the commands used in this tutorial are specifically for the Ubuntu system, all the methods are also valid for any other Linux-based system.
Docker is included and comes by default with the Ubuntu system. Install the Docker through the following steps.
Always update your system repositories before any installation.
sudo apt update
Remove any older version of Docker using the following command for a fresh installation.
sudo apt-get remove docker docker-engine docker.io
Next, install Docker by running the following apt command.
sudo apt install docker.io
Check the Docker version with the following command.
docker --version
You can see the version is not the latest available version, you have to install it from its official repository to get the latest available version.
Update the system repositories by running the following command.
sudo apt update
Install the dependency packages to access the Docker repository over HTTPS.
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
To add the GPG key of the Docker repository, run the following command.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Next, to install the Docker repository, run.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
And update your system again.
sudo apt update
Finally, install Docker using the following command.
sudo apt-get install docker-ce
To verify that you have the latest available version of Docker on your system, run the following command.
docker --version
You can start and enable Docker services using the following commands.
sudo systemctl start docker sudo systemctl enable docker
Verify that the Docker service has started by its status.
sudo systemctl status docker
You can see that the Docker service is running.
Similarly, you can run the systemctl commands to stop and disable the Docker services.
sudo systemctl disable docker
Disabling the services will make sure that Docker services will not automatically start at system boot.
sudo systemctl stop docker
You can remove Docker from your system with the following commands
sudo apt-get remove docker docker-engine docker.io
sudo apt-get remove docker.ce
To run a container in Docker, use the following command.
sudo docker run <container>
You can see that sudo or root privilege is required to run Docker. To opt-out of this, you have to add the docker group to sudo and then the user in the docker group. To do that, run the following commands.
sudo groupadd docker sudo usermod -aG docker <user>
Run the following command for changes to take effect.
su - <user>
And verify the changes.
id -nG
You can see the docker group in the output. Now you can run Docker commands without sudo.
docker run hello-world
To search for a specific Docker image, you can search with the image name in Docker.
docker search <image-name>
Or you can list all the images with the following command.
docker images
Similarly, you can list all the containers in Docker with the following command.
docker container ps -a
Docker is an extremely flexible technology with various applications in software development. Docker will ease the way you distribute software in diverse settings and is excellent for testing and prototyping applications, whether you are a software developer or work in DevOps.
This tutorial discussed how you can install and uninstall dockers on your Ubuntu system. It also briefly teaches some basic use of Docker.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…