Docker CentOS7的系统上安装部署以及基础教程
说明:
本文介绍如何在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.repo name=docker repository baseurl=https://yum.dockerproject.org/repo/main/centos/7 enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg eof
4 安装docker软件包
yum install docker-engine
5 启动docker服务
service docker start
6 测试运行下hello-world镜像
docker run hello-world
7 查看docker信息
使用docker info 命令可以参考系统、docker的详细信息:
docker info containers: 3 images: 2 server version: 1.9.0 storage driver: devicemapper pool name: docker-253:0-202597120-pool pool blocksize: 65.54 kb base device size: 107.4 gb backing filesystem: xfs data file: /dev/loop2 metadata file: /dev/loop3 data space used: 1.824 gb data space total: 107.4 gb data space available: 47.87 gb metadata space used: 1.655 mb metadata space total: 2.147 gb metadata space available: 2.146 gb udev sync supported: true deferred removal enabled: false deferred deletion enabled: false deferred deleted device count: 0 data loop file: /var/lib/docker/devicemapper/devicemapper/data metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata library version: 1.02.93-rhel7 (2015-01-28) execution driver: native-0.2 logging driver: json-file kernel version: 3.10.0-229.20.1.el7.x86_64 operating system: centos linux 7 (core) cpus: 24 total memory: 11.57 gib name: localhost.localdomain id: 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] ~]# ifconfig docker0: flags=4163 mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0 inet6 fe80::42:84ff:fe7f:4510 prefixlen 64 scopeid 0x20 ether 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 0 tx packets 3 bytes 258 (258.0 b) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (local loopback) rx packets 20530318 bytes 1812359321 (1.6 gib) rx errors 0 dropped 0 overruns 0 frame 0 tx packets 20530318 bytes 1812359321 (1.6 gib) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0 veth9422d62: flags=4163 mtu 1500 inet6 fe80::6c36:d0ff:fef5:3996 prefixlen 64 scopeid 0x20 ether 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 0 tx packets 10 bytes 828 (828.0 b) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [[email protected] ~]# brctl show bridge name bridge id stp enabled interfaces docker0 8000.0242847f4510 no veth9422d62 [[email protected] ~]#
感谢阅读,希望能帮助到大家,谢谢对本站的支持!
推荐阅读