How to install docker in Linux

PHPz
Release: 2023-04-25 17:27:28
Original
1131 people have browsed it

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:

  1. Install the official Docker apt package

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
Copy after login

The above command will download and install Docker CE and containerd.io from the official.

  1. Use the official installation script

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
Copy after login
Copy after login

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:

  1. Install the official Docker yum package

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
Copy after login

The above command will download and install Docker CE and containerd.io from the official.

  1. Use the official installation script

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
Copy after login
Copy after login

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:

  1. Start Docker

In Ubuntu, use the following command to start Docker:

$ sudo systemctl start docker
Copy after login
Copy after login

In CentOS, use the following Command to start Docker:

$ sudo systemctl start docker
Copy after login
Copy after login
  1. Set Docker to start automatically at boot

In Ubuntu, use the following command to set Docker to start automatically at boot:

$ sudo systemctl enable docker
Copy after login
Copy after login

In CentOS , use the following command to set Docker to start automatically at boot:

$ sudo systemctl enable docker
Copy after login
Copy after login
  1. Using Docker

After installing Docker, you can use the following command to verify whether the installation is successful:

$ sudo docker run hello-world
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!