Table of contents
1. Ubuntu
Docker is a powerful tool for developing, deploying, and running applications in containers. It is available for a variety of operating systems, including Ubuntu.
To install Docker using package managers on Ubuntu, you can use the following steps:
1. Update the package cache
sudo apt update
2. Install the Docker package
sudo apt install docker-ce
3. Verify the installation
docker version
This command should output the version of Docker that is installed on your system.
4. Add the current user to the docker group
sudo usermod -aG docker ${USER}
This will allow you to run Docker commands without having to use sudo.
5. Log out and log back in
This is necessary for the changes to take effect.
Once you have completed these steps, you will be able to use Docker on your Ubuntu system.
All steps in one frame::
The following code lines shows how to install Docker using package managers on Ubuntu:
# Update the package cache
sudo apt update
# Install the Docker package
sudo apt install docker-ce
# Verify the installation
docker version
# Add the current user to the docker group
sudo usermod -aG docker ${USER}
# Log out and log back in
Explanation
The following is an explanation of the commands used in the example:
apt update
: This command updates the package cache, which is a list of all the software packages that are available for installation.apt install docker-ce
: This command installs the Docker package on your system.docker version
: This command outputs the version of Docker that is installed on your system.usermod -aG docker ${USER}
: This command adds the current user to thedocker
group. This is necessary so that you can run Docker commands without having to use sudo.log out and log back in
: This is necessary for the changes to take effect.
2. CentOS
To install Docker using package managers on CentOS, you can use the following steps:
- Update your package manager:
sudo yum update
- Install the Docker package:
sudo yum install docker-ce
- Enable the Docker service:
sudo systemctl enable docker.service
- Start the Docker service:
sudo systemctl start docker.service
- Verify that Docker is installed and running:
docker info
This command should output information about your Docker installation, such as the Docker version and the Docker daemon status.
Explanation of commands:
sudo
: This command allows you to run the following command with root privileges.yum update
: This command updates your package manager's database of available packages.yum install docker-ce
: This command installs the Docker package.systemctl enable docker.service
: This command enables the Docker service so that it will start automatically when the system boots up.systemctl start docker.service
: This command starts the Docker service.docker info
: This command displays information about your Docker installation.
All Steps in one frame:
The following code lines shows how to install Docker using package managers on CentOS:
# Update the package manager
sudo yum update
# Install the Docker package
sudo yum install docker-ce
# Enable the Docker service
sudo systemctl enable docker.service
# Start the Docker service
sudo systemctl start docker.service
# Verify that Docker is installed and running
docker info
Output:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.13 (build 568c63e)
Engine Version: 20.10.13
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay2 Support: true
System Status: Running
You can also find installation steps on https://docs.docker.com/desktop/install/linux-install/ or for your required operating system, such as macOS or Windows. For better understanding, I wrote this blog to simplify installation on Ubuntu/CentOS (open-source development version of RHEL).