Home >Operation and Maintenance >CentOS >How to install docker on centos
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
Prerequisites:
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>
2. Install Docker engine
<code class="bash">sudo yum install docker-ce docker-ce-cli containerd.io</code>
3. Enable and start Docker
<code class="bash">sudo systemctl start docker sudo systemctl enable docker</code>
4. Verify installation
<code class="bash">sudo docker run hello-world</code>
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>
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>
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>
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!