说明:
本文介绍如何在CentOS7的系统上安装部署Docker环境,本文参考Docker官方文档如下链接:
https://docs.docker.com/engine/installation/centos/
CentOS7的系统上安装部署Docker环境
1 CentOS7安装(略)
2 升级系统
yum update
升级完成后需要重启下系统。
3 添加docker yum源
执行如下命令:
cat >/etc/yum.repos.d/docker.reponame=DockerRepository baseurl=https://yum.dockerproject.org/repo/main/centos/7enabled=1gpgcheck=1gpgkey=https://yum.dockerproject.org/gpgEOF
4 安装Docker软件包
yum install docker-engine
5 启动Docker服务
service docker start
6 测试运行下hello-world镜像
docker run hello-world
7 查看docker信息
使用docker info 命令可以参考系统、Docker的详细信息:
docker infoContainers: 3Images: 2Server Version: 1.9.0Storage Driver: devicemapperPool Name: docker-253:0-202597120-poolPool Blocksize: 65.54 kBBase Device Size: 107.4 GBBacking Filesystem: xfsData file: /dev/loop2Metadata file: /dev/loop3Data Space Used: 1.824 GBData Space Total: 107.4 GBData Space Available: 47.87 GBMetadata Space Used: 1.655 MBMetadata Space Total: 2.147 GBMetadata Space Available: 2.146 GBUdev Sync Supported: trueDeferred Removal Enabled: falseDeferred Deletion Enabled: falseDeferred Deleted Device Count: 0Data loop file: /var/lib/docker/devicemapper/devicemapper/dataMetadata loop file: /var/lib/docker/devicemapper/devicemapper/metadataLibrary Version: 1.02.93-RHEL7 (2015-01-28)Execution Driver: native-0.2Logging Driver: json-fileKernel Version: 3.10.0-229.20.1.el7.x86_64Operating System: CentOS Linux 7 (Core)CPUs: 24Total Memory: 11.57 GiBName: localhost.localdomainID: VIAJ:MW46:FVFJ:QN7G:XI66:OUBO:M65B:KAUE:BIPC:LL5D:HBCL:762N
8 创建docker用户组,并将用户放到docker组内部
建议使用非root用户运行docker,因为root用户运行docker镜像非常不安全。
创建test1用户,并将用户加入到docker用户组:
[[email protected]~]# useradd test1
[[email protected]~]# usermod -aG docker test1
切到test1用户,运行docker镜像:
[[email protected]~]# su test1
[[email protected]]$
[[email protected]]$ docker run hello-world
9 设置dock服务开机启动
chkconfig docker on
10 卸载Docker
yum list installed | grep docker
yum -y remove docker-engine.x86_64
rm -rf /var/lib/docker
然后删除相关用户。
补充说明:
关于Docker的网络
和kvm类似,看起来也是使用网桥的方式:
[[email protected] ~]# ifconfigdocker0: flags=4163 mtu 1500inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0inet6 fe80::42:84ff:fe7f:4510 prefixlen 64 scopeid 0x20ether 02:42:84:7f:45:10 txqueuelen 0 (Ethernet)RX packets 12 bytes 840 (840.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 3 bytes 258 (258.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10loop txqueuelen 0 (Local Loopback)RX packets 20530318 bytes 1812359321 (1.6 GiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 20530318 bytes 1812359321 (1.6 GiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0veth9422d62: flags=4163 mtu 1500inet6 fe80::6c36:d0ff:fef5:3996 prefixlen 64 scopeid 0x20ether 6e:36:d0:f5:39:96 txqueuelen 0 (Ethernet)RX packets 8 bytes 648 (648.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 10 bytes 828 (828.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[[email protected] ~]# brctl showbridge name bridge id STP enabled interfacesdocker0 8000.0242847f4510 no veth9422d62[[email protected] ~]#
感谢阅读,希望能帮助到大家,谢谢对本站的支持!
新闻热点
疑难解答
图片精选