Docker is a very popular containerization technology that can easily create, deploy and run applications. It is widely used in development, testing and production environments. Installing Docker in a Linux system is also very simple. This article will introduce how to install Docker in different Linux distributions.
1. Ubuntu
There are many ways to install Docker in Ubuntu, the following are two of them:
Use the apt-get command to install the official Docker apt package:
$ sudo apt-get update $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io
The above command will download and install Docker CE and containerd.io from the official.
You can also use the official installation script to install Docker:
$ curl -fsSL https://get.docker.com -o get-docker.sh $ sudo sh get-docker.sh
The above command will be downloaded and executed from the Docker official website Install script.
2. CentOS
There are many ways to install Docker in CentOS. The following are two of them:
Use the yum command to install the official Docker yum package:
$ sudo yum install -y yum-utils $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo $ sudo yum install docker-ce docker-ce-cli containerd.io
The above command will download and install Docker CE and containerd.io from the official.
You can also use the official installation script to install Docker:
$ curl -fsSL https://get.docker.com -o get-docker.sh $ sudo sh get-docker.sh
The above command will be downloaded and executed from the Docker official website Install script.
3. Other Linux distributions
In addition to Ubuntu and CentOS, the methods of installing Docker in other Linux distributions are similar. You can download the corresponding installation package or script from the Docker official website and install it.
4. Configuring Docker
After installing Docker, you still need to perform related configurations for normal use. The following are some common configurations:
In Ubuntu, use the following command to start Docker:
$ sudo systemctl start docker
In CentOS, use the following Command to start Docker:
$ sudo systemctl start docker
In Ubuntu, use the following command to set Docker to start automatically at boot:
$ sudo systemctl enable docker
In CentOS , use the following command to set Docker to start automatically at boot:
$ sudo systemctl enable docker
After installing Docker, you can use the following command to verify whether the installation is successful:
$ sudo docker run hello-world
This command will download the hello-world image officially provided by Docker and start a container to run it.
Summary
Docker is a very popular containerization technology that makes it easy to create, deploy, and run applications. Installing Docker in a Linux system is also very simple. You only need to download the installation package or script and configure it accordingly. After installation, you can use Docker to create and manage containers with simple commands.
The above is the detailed content of How to install docker in Linux. For more information, please follow other related articles on the PHP Chinese website!