文档章节

Centos7 下安装 Docker

architect刘源源
 architect刘源源
发布于 2018/12/24 17:10
字数 2064
阅读 35
收藏 2

9.2 7 Centos7 下安装  Docker
9.2.1 配置虚拟机
docker 官方文档要求必须运行在 Linux kernel 3.8 以上,所以需要安装在 Centos7
或者 Ubantu 系统上。
yum install lrzsz #安装上传下载组件
uname –a #检查当前 Linux 内核版本
查询结果:
Linux tdocker 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015
x86_64 x86_64 x86_64 GNU/Linux
9.2.2 VM 配置 NAT 模式网络上网
修改配置文件
cd /etc/sysconfig/network-scripts #进入网络配置目录
dir ifcfg* #找到网卡配置文件
ifcfg-eno16777736 ifcfg-lo
vi ifcfg-eno16777736
配置文件内容
TYPE=Ethernet
BOOTPROTO=static #改成 static,针对 NAT
NAME=eno16777736
UUID=4cc9c89b-cf9e-4847-b9ea-ac713baf4cc8
DEVICE=eno16777736
ONBOOT=yes #开机启动此网卡
IPADDR=192.168.163.30 #固定 IP 地址
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.163.2 #网关和 NAT 自动配置的相同,不同则无法登录
DNS1=192.168.163.2 #和网关相同
测试
centos7命令发生巨大变化
ip addr #查看 IP 地址 ip add
service network restart #重启网络
systemctl restart network.service #重启网络 centos7
vi /etc/hosts #127.0.0.1 dredis
hostname dreids #注意必须修改机器名 hostname
ping www.baidu.com #如果出现 baidu 的 ip 地址则表示网络连通
9.2.3 安装 Docker
9.2.3.1 第一步:安装工具包
$ sudo yum install -y yum-utils #安装工具包,缺少这些依赖将无法完成
执行结果:
Loaded plugins: fastestmirror, langpacks
base
| 3.6 kB 00:00:00
epel
| 4.3 kB 00:00:00
extras
| 3.4 kB 00:00:00
update
| 3.4 kB 00:00:00
(1/3): epel/7/x86_64/updateinfo
| 797 kB 00:00:00
(2/3): epel/7/x86_64/primary_db
| 4.7 MB 00:00:00
(3/3): update/7/x86_64/primary_db
| 4.8 MB 00:00:00
Loading mirror speeds from cached hostfile
Package yum-utils-1.1.31-40.el7.noarch already installed and latest
version
Nothing to do
9.2.3.2 第二步:设置远程仓库
$sudo yum-config-manager --add-repo
https://download.docker.com/linux/centos/docker-ce.repo
执行结果:
Loaded plugins: fastestmirror, langpacks
adding repo from:
https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo
to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
9.2.3.3 第三步:安装
$ sudo yum install docker-ce
执行结果:
Loaded plugins: fastestmirror, langpacks
docker-ce-stable
| 2.9 kB 00:00:00
docker-ce-stable/x86_64/primary_db
| 4.8 kB 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.1.ce-1.el7.centos will be
installed
--> Processing Dependency: docker-ce-selinux >= 17.03.1.ce-1.el7.centos
for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libcgroup for package:
docker-ce-17.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package:
docker-ce-17.03.1.ce-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos will be
installed
--> Processing Dependency: policycoreutils-python for package:
docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch
---> Package libcgroup.x86_64 0:0.41-11.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-2.el7 will be installed
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-11.el7_3 will be
installed
--> Processing Dependency: setools-libs >= 3.3.8-1 for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-5 for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: python-IPy for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: checkpolicy for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package:
policycoreutils-python-2.5-11.el7_3.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.6.5-3.el7_3.1 will be
installed
---> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-5.1.el7_3 will be
installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================
=================================================
Package Arch Version
Repository Size
====================================================================
=================================================
Installing:
docker-ce x86_64
17.03.1.ce-1.el7.centos docker-ce-stable 19 M
Installing for dependencies:
audit-libs-python x86_64 2.6.5-3.el7_3.1
update 70 k
checkpolicy x86_64 2.5-4.el7
base 290 k
docker-ce-selinux noarch
17.03.1.ce-1.el7.centos docker-ce-stable 28 k
libcgroup x86_64 0.41-11.el7
base 65 k
libseccomp x86_64 2.3.1-2.el7
base 56 k
libsemanage-python x86_64 2.5-5.1.el7_3
update 104 k
policycoreutils-python x86_64 2.5-11.el7_3
update 445 k
python-IPy noarch 0.75-6.el7
base 32 k
setools-libs x86_64 3.3.8-1.1.el7
base 612 k
Transaction Summary
====================================================================
=================================================
Install 1 Package (+9 Dependent packages)
Total download size: 20 M
Installed size: 24 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): audit-libs-python-2.6.5-3.el7_3.1.x86_64.rpm
| 70 kB 00:00:00
(2/10): checkpolicy-2.5-4.el7.x86_64.rpm
| 290 kB 00:00:00
(3/10): libseccomp-2.3.1-2.el7.x86_64.rpm
| 56 kB 00:00:00
(4/10): libcgroup-0.41-11.el7.x86_64.rpm
| 65 kB 00:00:00
(5/10): policycoreutils-python-2.5-11.el7_3.x86_64.rpm
| 445 kB 00:00:00
(6/10): setools-libs-3.3.8-1.1.el7.x86_64.rpm
| 612 kB 00:00:00
(7/10): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm
| 104 kB 00:00:00
(8/10): python-IPy-0.75-6.el7.noarch.rpm
| 32 kB 00:00:00
warning:
/var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-selinux-17.
03.1.ce-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID
621e9f35: NOKEY
Public key for docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm is
not installed
(9/10): docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
| 28 kB 00:00:00
(10/10): docker-ce-17.03.1.ce-1.el7.centos.x86_64.rpm
| 19 MB 00:00:00
--------------------------------------------------------------------
-------------------------------------------------
Total
23 MB/s | 20 MB 00:00:00
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libcgroup-0.41-11.el7.x86_64
1/10
Installing : setools-libs-3.3.8-1.1.el7.x86_64
2/10
Installing : checkpolicy-2.5-4.el7.x86_64
3/10
Installing : libsemanage-python-2.5-5.1.el7_3.x86_64
4/10
Installing : audit-libs-python-2.6.5-3.el7_3.1.x86_64
5/10
Installing : python-IPy-0.75-6.el7.noarch
6/10
Installing : policycoreutils-python-2.5-11.el7_3.x86_64
7/10
Installing : docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch
8/10
setsebool: SELinux is disabled.
libsemanage.semanage_direct_install_info: Overriding docker module at
lower priority 100 with module at priority 400.
Installing : libseccomp-2.3.1-2.el7.x86_64
9/10
Installing : docker-ce-17.03.1.ce-1.el7.centos.x86_64
10/10
Verifying : libseccomp-2.3.1-2.el7.x86_64
1/10
Verifying : python-IPy-0.75-6.el7.noarch
2/10
Verifying : audit-libs-python-2.6.5-3.el7_3.1.x86_64
3/10
Verifying : libsemanage-python-2.5-5.1.el7_3.x86_64
4/10
Verifying : docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch
5/10
Verifying : libcgroup-0.41-11.el7.x86_64
6/10
Verifying : policycoreutils-python-2.5-11.el7_3.x86_64
7/10
Verifying : docker-ce-17.03.1.ce-1.el7.centos.x86_64
8/10
Verifying : checkpolicy-2.5-4.el7.x86_64
9/10
Verifying : setools-libs-3.3.8-1.1.el7.x86_64
10/10
Installed:
docker-ce.x86_64 0:17.03.1.ce-1.el7.centos
Dependency Installed:
audit-libs-python.x86_64 0:2.6.5-3.el7_3.1
checkpolicy.x86_64 0:2.5-4.el7
docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos
libcgroup.x86_64 0:0.41-11.el7
libseccomp.x86_64 0:2.3.1-2.el7
libsemanage-python.x86_64 0:2.5-5.1.el7_3
policycoreutils-python.x86_64 0:2.5-11.el7_3
python-IPy.noarch 0:0.75-6.el7
setools-libs.x86_64 0:3.3.8-1.1.el7
Complete!
9.2.3.4 第四步:启动
或者
$ sudo service docker start
service docker start #启动 docker
chkconfig docker on #加入开机启动
9.2.3.5 第五步:查看版本
$ sudo docker version
执行结果:
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:05:44 2017
OS/Arch: linux/amd64
9.2.3.6 第六步:校验
$ sudo docker run hello-world
执行结果:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest:
sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for 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.
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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
9.2.4 查看 Docker 版本
docker --help #帮助
docker –v #简单查看版本
docker version #查看版本
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d/1.7.1
OS/Arch (server): linux/amd64
docker info #查看信息
Containers: 0
Images: 2
Storage Driver: devicemapper
Pool Name: docker-253:0-34097258-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 308.3 MB
Data Space Total: 107.4 GB
Data Space Available: 16.08 GB
Metadata Space Used: 782.3 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file:
/var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.107-RHEL7 (2015-10-14)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 4
Total Memory: 985.6 MiB
Name: localhost.localdomain
ID: B5ZW:FJXF:FNUD:OLH7:FCNI:56DJ:XEQY:I6J4:PPHQ:OKRW:CIJK:Y26P
9.2.5 安装其它产品的两种方式
docker 安装其它产品有两种方式
方式一:通过拉取事先做好的镜像,例如下面 redis 的安装方式
方式二:通过 Dockerfile 来构建新的镜像,例如下面 tomcat 的安装方式
9.2.6 组成结构
docker 会自动给 docker 容器配置一个 vip 虚拟 ip 地址
bash-4.1#提示符就代表进入 docker 容器内部

© 著作权归作者所有

上一篇: juc
下一篇: Docker 容器简介
architect刘源源

architect刘源源

粉丝 164
博文 518
码字总数 922746
作品 0
浦东
程序员
私信 提问
Docker实践(一):安装

前提 系统:我这边都使用虚拟机安装的CentOS7,具体安装可以参考:Windows安装Linux虚拟机(CentOS7) yum:推荐更新下yum:yum update;我们这边CentOS7自带docker,如果没有安装docker可以用y...

u010246789
2016/12/31
0
0
Docker自制镜像之私有云平台完整版

一、Docker安装 Docker之安装篇 二、Docker操作 搜索中央仓库可用镜像 $ docker search centos 2.1【镜像操作命令】 2.1.1 查看所有镜像docker images删除所有镜像 $ docker rmi $(docker im...

saxon_i
2018/08/13
0
0
CentOS快速安装docker服务

  前言   2017 年 3 月,Docker从1.13.x版本开始,版本分为企业版EE和社区版CE,版本号也改为按照时间线来发布,比如17.03就是2017年3月。企业版本是需要付费的,强调安全。      d...

linux运维菜
2018/08/26
0
0
centos7系统下 docker 环境搭建

运行环境: VMware Workstation Pro 在虚拟机中安装centos7系统, 选择最小安装, 网络连接方式选择的桥接(与宿主机在同一IP段) centos7一定要安装64位, docker目前不支持32位内核 ##看准了, 是...

qq_33326449
2018/03/20
0
0
Centos7制作docker初始镜像

Centos7用febootstrap制作docker初始镜像包 使用工具:febootstrap 下载地址:http://down.51cto.com/data/2330414 使用命令: febootstrap -i bash -i wget -i yum -i iputils -i iproute -......

vanche
2017/07/30
0
0

没有更多内容

加载失败,请刷新页面

加载更多

巨杉Tech | 微服务趋势下的数据库设计与应用简析

上周五(7月12日)巨杉数据库参与了由得到App主办八里庄技术沙龙活动,分享主题是关于分布式数据库架构与实战。 以下就是根据巨杉数据库现场分享的内容进行的分享实录整理。 巨杉数据库简介 ...

巨杉数据库
18分钟前
9
0
借助URLOS快速安装AliSQL

环境需求 最低硬件配置:1核CPU,1G内存(1+1)提示:如果你的应用较多,而主机节点的硬件配置较低,建议在部署节点时开通虚拟虚拟内存; 生产环境建议使用2G或以上内存; 推荐安装系统:Ubu...

躲猫猫_007
19分钟前
0
0
DM 源码阅读系列文章(九)shard DDL 与 checkpoint 机制的实现

作者:张学程 本文为 DM 源码阅读系列文章的第九篇,在 上篇文章 中我们详细介绍了 DM 对 online schema change 方案的同步支持,对 online schema change 同步方案以及实现细节等逻辑进行了...

TiDB
21分钟前
0
0
mysql指令

mysql指令 连接数据库 mysql -h 127.0.0.1 -u root -p -h : 数据库地址 -u : 用户名 -p : 密码 显示所有数据库 show databases; //显示所有数据库use XXX; //使用指定数据库show t...

xiaobai1315
25分钟前
0
0
C++STL常见面试题

1.C++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构操作。vector封装数组,...

shzwork
35分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部