Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker Learning 1:CentOS Docker installation

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Reference:

Http://www.runoob.com/docker/centos-docker-install.html

CentOS Docker installation

Docker supports the following CentOS versions:

CentOS 7 (64-bit)

CentOS 6.5 (64-bit) or later

prerequisite

Currently, only kernels in CentOS distributions support Docker.

Docker runs on CentOS 7 and requires a 64-bit system with a kernel version of 3.10 or above.

Docker runs on CentOS-6.5 or later CentOS and requires the system to be 64-bit and the system kernel version 2.6.32-431 or later.

Install using yum (under CentOS 7)

Docker requires the kernel version of the CentOS system to be higher than 3.10. check the prerequisites on this page to verify that your version of CentOS supports Docker.

Check your current kernel version with the uname-r command

[root@huixuan] # uname-a

Linux huixuan 3.10.0-514.el7.x86_64 # 1 SMP Tue Nov 22 16:42:41 UTC 2016 x86'64 GNU/Linux

[root@huixuan ~] #

Install Docker

The Docker package and dependency packages are already included in the default CentOS-Extras software source, with the following installation commands:

Start the Docker background service

Service docker start

After that, you need to modify: the default segment of Docker0 bridge

[root@huixuan ~] # ps-ef | grep docker

Root 3691 10 17:28 00:00:00 / usr/bin/dockerd-current-- add-runtime docker-runc=/usr/libexec/docker/docker-runc-current-- default-runtime=docker-runc-- exec-opt native.cgroupdriver=systemd-- userland-proxy-path=/usr/libexec/docker/docker-proxy-current-- seccomp-profile=/etc/docker/seccomp.json-- selinux-enabled-- log-driver=journald-- signature-verification=false-- storage-driver overlay2

Root 3698 3691 0 17:28? 00:00:00 / usr/bin/docker-containerd-current-l unix:///var/run/docker/libcontainerd/docker-containerd.sock-- metrics-interval=0-- start-timeout 2m-- state-dir / var/run/docker/libcontainerd/containerd-- shim docker-containerd-shim-- runtime docker-runc-- runtime-args-- systemd-cgroup=true

Root 3838 3817 0 17:30 pts/0 00:00:00 grep-color=auto docker

[root@huixuan ~] #

Test run hello-world

[root@huixuan ~] # docker run hello-world

Unable to find image 'hello-world:latest' locally

Trying to pull repository docker.io/library/hello-world...

Latest: Pulling from docker.io/library/hello-world

9bb5a5d4561a: Pull complete

Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77

Status: Downloaded newer image for docker.io/hello-world:latest

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

(amd64)

3. The Docker daemon created a new container from that image which runs the

Executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it

To your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$docker run-it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

Https://hub.docker.com/

For more examples and ideas, visit:

Https://docs.docker.com/engine/userguide/

[root@huixuan ~] #

Install Docker using a script

1. Log in to Centos with sudo or root permissions.

2. Make sure the yum package is up to date.

Yum update

3. Execute Docker installation script.

[root@huixuan ~] # curl-fsSL https://get.docker.com/ | sh

# Executing docker install script, commit: 36b78b2

Warning: the "docker" command appears to already exist on this system.

If you already have Docker installed, this script can cause trouble, which is

Why we're displaying this warning and provide the opportunity to cancel the

Installation.

Executing this script adds the docker.repo source and installs Docker.

4. Start Docker process.

[root@huixuan ~] # service docker start

Redirecting to / bin/systemctl start docker.service

5. Verify that docker is installed successfully and execute a test image in the container.

[root@huixuan ~] # docker run hello-world

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

(amd64)

3. The Docker daemon created a new container from that image which runs the

Executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it

To your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$docker run-it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

Https://hub.docker.com/

For more examples and ideas, visit:

Https://docs.docker.com/engine/userguide/

[root@huixuan ~] #

At this point, the installation of docker on the CentOS system is complete.

Mirror acceleration

In view of the domestic network problems, it is very slow to pull the Docker image later. We can configure an accelerator to solve it. I use NetEase's image address: http://hub-mirror.c.163.com.

The new version of Docker uses / etc/docker/daemon.json (Linux) or% programdata%\ docker\ config\ daemon.json (Windows) to configure Daemon.

Please add to the configuration file (if there is no such file, please create one first):

[root@huixuan ~] # cat / etc/docker/daemon.json

{

"registry-mirrors": ["http://hub-mirror.c.163.com"]"

"bip": "192.168.100.1 Universe 24"

}

[root@huixuan ~] #

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report