How to install docker on centos

下次还敢
Release: 2024-04-07 19:51:15
Original
553 people have browsed it

To install Docker on CentOS, please perform the following steps: 1. Add the Docker official repository; 2. Install the Docker engine; 3. Enable and start Docker; 4. Verify the installation; 5. Add the user to the Docker group ;6. Log out and log in again; 7. Test the Docker access permissions of non-root users.

How to install docker on centos

How to install Docker on CentOS

Prerequisites:

  • CentOS 7 or higher
  • User with root privileges

Steps:

1. Add Docker official repository

<code class="bash">sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo</code>
Copy after login

2. Install Docker engine

<code class="bash">sudo yum install docker-ce docker-ce-cli containerd.io</code>
Copy after login

3. Enable and start Docker

<code class="bash">sudo systemctl start docker
sudo systemctl enable docker</code>
Copy after login

4. Verify installation

<code class="bash">sudo docker run hello-world</code>
Copy after login

If the output is similar to the following, Docker has been successfully installed and running:

<code>Hello from Docker!
This message shows that your installation appears to be working correctly.</code>
Copy after login

5. Add user to Docker Group

To allow non-root users to run Docker commands, you need to add them to the docker group:

<code class="bash">sudo groupadd docker
sudo usermod -aG docker $USER</code>
Copy after login

6. Log out and log back in

After making the group membership changes take effect, you need to log out and back in to use Docker commands.

7. Test Docker access for non-root users

Now you can run Docker commands using non-root users, for example:

<code class="bash">docker run -it alpine /bin/sh</code>
Copy after login

If everything Normally, you should see the Alpine Linux shell prompt.

The above is the detailed content of How to install docker on centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template