docker技术发展速度很快,从15年接触docker到现在已经两年了,两年来docker变化很大,百度一下也会发现一大片的技术博客,关于技术书籍出版的也不少,但很多书都是出版就意味着过时.
新技术层出不穷,在学完k8s之后,回过头来总结下docker和k8s,以备后用.
所用系统:centos 7
在安装之前我们需要介绍下环境:
1. 网络使用的是dhcp,可以ping通百度
[root@xinsz08 ~]# ping www.baidu.com PING www.a.shifen.com (119.75.213.61) 56(84) bytes of data. 64 bytes from 119.75.213.61: icmp_seq=1 ttl=56 time=5.48 ms 64 bytes from 119.75.213.61: icmp_seq=2 ttl=56 time=7.26 ms 64 bytes from 119.75.213.61: icmp_seq=3 ttl=56 time=5.55 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 5.486/6.102/7.266/0.823 ms
2.防火墙是开启的
[root@xinsz08 ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since 日 2017-09-24 09:52:02 CST; 2 days ago Main PID: 926 (firewalld) CGroup: /system.slice/firewalld.service └─926 /usr/bin/python -Es /usr/sbin/firewalld --nofork ... 9月 24 09:52:03 xinsz08 systemd[1]: Starting firewalld - dynamic.... 9月 24 09:52:02 xinsz08 systemd[1]: Started firewalld - dynamic .... Hint: Some lines were ellipsized, use -l to show in full.
3. selinux是开启的
[root@xinsz08 ~]# getenforce
接下来我们开始安装docker:
1.安装所需要的包
Install required packages. yum-utils provides the yum-config-managerutility, and device-mapper-persistent-data and lvm2 are required by thedevicemapper storage driver.
# yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-utils :
功能:管理repository 及扩展包工具
device-mapper-persistent-data 设备映射持久化数据的存储
2. 使用下列命令建立稳定的库
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
1)安装docker
$ sudo yum install docker-ce
2) 启动docker
systemctl start docker
3) 测试
docker run hello-world
4.查看docker版本