docker学习1:CentOS Docker 安装
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,参考:http://www.runoob.com/docker/centos-docker-install.htmlCentOS Docker 安装Docker支持以下的CentOS版本:CentOS
千家信息网最后更新 2025年12月02日docker学习1:CentOS Docker 安装参考:
http://www.runoob.com/docker/centos-docker-install.html
CentOS Docker 安装
Docker支持以下的CentOS版本:
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
前提条件
目前,CentOS 仅发行版本中的内核支持 Docker。
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。
使用 yum 安装(CentOS 7下)
Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。
通过 uname -r 命令查看你当前的内核版本
[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 x86_64 x86_64 GNU/Linux
[root@huixuan ~]#
安装 Docker
Docker 软件包和依赖包已经包含在默认的 CentOS-Extras 软件源里,安装命令如下:
启动 Docker 后台服务
service docker start
之后需要修改:Docker0网桥默认网段
[root@huixuan ~]# ps -ef | grep docker
root 3691 1 0 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 ~]#
测试运行 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 ~]#
使用脚本安装 Docker
1、使用 sudo 或 root 权限登录 Centos。
2、确保 yum 包更新到最新。
yum update
3、执行 Docker 安装脚本。
[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.
执行这个脚本会添加 docker.repo 源并安装 Docker。
4、启动 Docker 进程。
[root@huixuan ~]# service docker start
Redirecting to /bin/systemctl start docker.service
5、验证 docker 是否安装成功并在容器中执行一个测试的镜像。
[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 ~]#
到此,docker 在 CentOS 系统的安装完成。
镜像加速
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,我使用的是网易的镜像地址:http://hub-mirror.c.163.com。
新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 来配置 Daemon。
请在该配置文件中加入(没有该文件的话,请先建一个):
[root@huixuan ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
"bip":"192.168.100.1/24"
}
[root@huixuan ~]#
http://www.runoob.com/docker/centos-docker-install.html
CentOS Docker 安装
Docker支持以下的CentOS版本:
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
前提条件
目前,CentOS 仅发行版本中的内核支持 Docker。
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。
使用 yum 安装(CentOS 7下)
Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。
通过 uname -r 命令查看你当前的内核版本
[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 x86_64 x86_64 GNU/Linux
[root@huixuan ~]#
安装 Docker
Docker 软件包和依赖包已经包含在默认的 CentOS-Extras 软件源里,安装命令如下:
启动 Docker 后台服务
service docker start
之后需要修改:Docker0网桥默认网段
[root@huixuan ~]# ps -ef | grep docker
root 3691 1 0 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 ~]#
测试运行 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 ~]#
使用脚本安装 Docker
1、使用 sudo 或 root 权限登录 Centos。
2、确保 yum 包更新到最新。
yum update
3、执行 Docker 安装脚本。
[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.
执行这个脚本会添加 docker.repo 源并安装 Docker。
4、启动 Docker 进程。
[root@huixuan ~]# service docker start
Redirecting to /bin/systemctl start docker.service
5、验证 docker 是否安装成功并在容器中执行一个测试的镜像。
[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 ~]#
到此,docker 在 CentOS 系统的安装完成。
镜像加速
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,我使用的是网易的镜像地址:http://hub-mirror.c.163.com。
新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 来配置 Daemon。
请在该配置文件中加入(没有该文件的话,请先建一个):
[root@huixuan ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
"bip":"192.168.100.1/24"
}
[root@huixuan ~]#
版本
系统
内核
镜像
脚本
支持
运行
配置
前提
命令
文件
条件
软件
测试
验证
缓慢
成功
加速器
后台
地址
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
xampp修改数据库设置
网络安全什么是逆向工程
云服务器自动运行脚本
图表配色软件开发
银行软件开发是什么意思
维护网络安全教育心得体会
网络安全大会门票
如何把网络安全的威胁解除
网络安全工程师学什么专业比较好
软件开发专业怎么答辩
数据库系统分析报告
深圳龙华软件开发公司
临泉职工网络安全知识竞赛
洛阳t3财务软件开发
徐州网络技术口碑推荐
花都小程序软件开发设计
数据库服务器的名称
电脑主机做服务器
关于21端口网络安全保障
今玖互联网科技信息有限公司
工程网络安全建设ppt
中国邮政储蓄银行软件开发部
国土资源厅网络安全宣传周活动
为什么黑月服务器名称不一样
部署本地服务器
谁统筹协调网络安全检测工作
数据库表知识点总结
服务器 做app
云服务器过户
网络技术的领域的应用