Install Docker on Oracle Enterprise Linux 7
初步配置该服务器,并让它可以访问公共网络(这不是必须的,你也可以选择把外网的YUM源移到本地,这里为了简便,故而让目标服务器联网。)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
[root@oel7 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.0 (Maipo) [root@oel7 ~]# [root@oel7 ~]# ifconfig docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.42.1 netmask 255.255.0.0 broadcast 0.0.0.0 ether 56:84:7a:fe:97:99 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.195.10 netmask 255.255.255.0 broadcast 192.168.195.255 inet6 fec0::17:20c:29ff:fe12:b460 prefixlen 64 scopeid 0x40<site> inet6 2002:a800:1b9:17:20c:29ff:fe12:b460 prefixlen 64 scopeid 0x0<global> inet6 fe80::20c:29ff:fe12:b460 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:12:b4:60 txqueuelen 1000 (Ethernet) RX packets 88473 bytes 102272807 (97.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 50567 bytes 3549215 (3.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 13 bytes 1360 (1.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13 bytes 1360 (1.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@oel7 ~]# [root@oel7 ~]# nslookup > server Default server: 192.168.195.1 Address: 192.168.195.1#53 > > baidu.com Server: 192.168.195.1 Address: 192.168.195.1#53 Non-authoritative answer: Name: baidu.com Address: 220.181.57.217 Name: baidu.com Address: 123.125.114.144 Name: baidu.com Address: 220.181.57.216 > > exit [root@oel7 ~]# |
上述的命令中“ifconfig”为我安装完Docker之后的采集结果,故而会看到多出了一块网卡“docker0”。
事实上,在Docker成功安装之前,是没有这块网卡的。
在网络的配置部分,只需要保证公网的网卡IP是你需要的,并且可以连上外网即可。
在本例中,公网网卡为:eno16777728,lo如字面意思所见“loop back = lo”,为本地回环地址。
关闭SELINUX:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@oel7 ~]# sestatus SELinux status: disabled [root@oel7 ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@oel7 ~]# |
关键配置是:SELINUX=disabled,默认该处为:enforciing(正在被强制启用)。
Oracle的公共YUM源(for Oracle Linux 7):http://public-yum.oracle.com/repo/OracleLinux/OL7/
如上图所示,配置YUM源的*.repo文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
[root@oel7 ~]# cat /etc/yum.repos.d/customer.repo [OL7-Addons] name=OEL7-Addons baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/ gpgcheck=0 [MySQL-56] name=MySQL-56 baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/MySQL56/x86_64/ gpgcheck=0 [UEKR3] name=UEKR3 baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR3/x86_64/ gpgcheck=0 [UEKR3-OFED20] name=UEKR3-OFED20 baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR3_OFED20/x86_64/ gpgcheck=0 [Latest] name=Latest baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/ gpgcheck=0 [Optional] name=Optional baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/optional/latest/x86_64/ gpgcheck=0 [SpaceWalker22] name=SpaceWalker22 baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/spacewalk22/client/x86_64/ gpgcheck=0 [root@oel7 ~]# |
设置YUM的本地缓存:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[root@oel7 ~]# cat /etc/yum.conf [main] #cachedir=/var/cache/yum/$basearch/$releasever cachedir=/software/yum/$basearch/$releasever keepcache=1 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=3 # This is the default, if you make this bigger yum won't see if the metadata # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. # It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d [root@oel7 ~]# |
然后,就可以安装Docker了:
1 2 3 4 5 6 |
[root@oel7 ~]# yum list | grep docker docker.x86_64 1.3.2-1.0.1.el7 @OL7-Addons docker-devel.x86_64 1.3.2-1.0.1.el7 OL7-Addons docker-pkg-devel.x86_64 1.3.2-1.0.1.el7 OL7-Addons docker-registry.noarch 0.6.8-8.el7 OL7-Addons [root@oel7 ~]# |
指令:
yum install docker
YUM会自动的处理掉包依赖性问题。
安装BtrFS:
1 2 3 4 5 6 |
[root@oel7 ~]# yum list | grep btrfs btrfs-progs.x86_64 3.12-4.el7 @anaconda/7.0 btrfs-progs.i686 3.12-4.el7 Latest btrfs-progs-devel.i686 3.12-4.el7 Optional btrfs-progs-devel.x86_64 3.12-4.el7 Optional [root@oel7 ~]# |
指令:
yum install btrfs-progs
关于BtrFS的文件系统的详细说明,请参阅:
https://btrfs.wiki.kernel.org/index.php/Main_Page
到这里为止,通过YUM需要安装的内容就结束了,你可以看看上面设定的YUM本地缓存中的状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
[root@oel7 software]# pwd /software [root@oel7 software]# ll total 319132 -rw-r--r-- 1 root root 326790656 Nov 11 04:34 oraclelinux-6.6.tar drwxr-xr-x. 3 root root 19 Dec 23 16:45 yum [root@oel7 software]# du -sh * 312M oraclelinux-6.6.tar 771M yum [root@oel7 software]# [root@oel7 software]# tree yum/ yum/ └── x86_64 └── 7Server ├── Latest │ ├── cachecookie │ ├── comps.xml │ ├── gen │ │ ├── other.xml │ │ ├── other.xml.sqlite │ │ ├── primary.xml │ │ ├── primary.xml.sqlite │ │ └── updateinfo.xml │ ├── other.xml.gz │ ├── packages │ │ ├── cronie-anacron-1.4.11-13.el7.x86_64.rpm │ │ ├── cups-filters-1.0.35-15.el7_0.1.x86_64.rpm │ │ ├── cups-filters-libs-1.0.35-15.el7_0.1.x86_64.rpm │ │ ├── cyrus-sasl-plain-2.1.26-17.0.1.el7.x86_64.rpm │ │ ├── dracut-network-033-161.el7_0.173.x86_64.rpm │ │ ├── fprintd-0.5.0-4.0.el7_0.x86_64.rpm │ │ ├── gcc-4.8.2-16.2.el7_0.x86_64.rpm │ │ ├── gdm-libs-3.8.4-28.0.1.el7_0.1.x86_64.rpm │ │ ├── git-1.8.3.1-4.el7.x86_64.rpm │ │ ├── glibc-devel-2.17-55.0.4.el7_0.3.x86_64.rpm │ │ ├── glibc-headers-2.17-55.0.4.el7_0.3.x86_64.rpm │ │ ├── gnome-shell-extension-alternate-tab-3.8.4-10.el7_0.noarch.rpm │ │ ├── gnome-shell-extension-apps-menu-3.8.4-10.el7_0.noarch.rpm │ │ ├── gnome-shell-extension-places-menu-3.8.4-10.el7_0.noarch.rpm │ │ ├── gnutls-dane-3.1.18-10.el7_0.x86_64.rpm │ │ ├── gtk2-immodule-xim-2.24.22-5.el7_0.1.x86_64.rpm │ │ ├── initscripts-9.49.17-1.0.1.el7_0.1.x86_64.rpm │ │ ├── iwl2000-firmware-18.168.6.1-35.el7_0.noarch.rpm │ │ ├── iwl3160-firmware-22.0.7.0-35.el7_0.noarch.rpm │ │ ├── iwl5000-firmware-8.83.5.1_1-35.el7_0.noarch.rpm │ │ ├── iwl6000g2a-firmware-17.168.5.3-35.el7_0.noarch.rpm │ │ ├── kernel-headers-3.10.0-123.13.2.el7.x86_64.rpm │ │ ├── libgomp-4.8.2-16.2.el7_0.x86_64.rpm │ │ ├── libsmbclient-4.1.1-37.el7_0.x86_64.rpm │ │ ├── libvirt-client-1.1.1-29.0.1.el7_0.3.x86_64.rpm │ │ ├── libvirt-daemon-1.1.1-29.0.1.el7_0.3.x86_64.rpm │ │ ├── libvirt-daemon-driver-secret-1.1.1-29.0.1.el7_0.3.x86_64.rpm │ │ ├── lzo-2.06-6.el7_0.2.x86_64.rpm │ │ ├── mesa-filesystem-9.2.5-6.20131218.el7_0.x86_64.rpm │ │ ├── mesa-libgbm-9.2.5-6.20131218.el7_0.x86_64.rpm │ │ ├── mesa-libGL-9.2.5-6.20131218.el7_0.x86_64.rpm │ │ ├── NetworkManager-0.9.9.1-29.git20140326.4dba720.el7_0.x86_64.rpm │ │ ├── NetworkManager-config-server-0.9.9.1-29.git20140326.4dba720.el7_0.x86_64.rpm │ │ ├── nss-3.16.2.3-2.0.1.el7_0.x86_64.rpm │ │ ├── nss-softokn-3.16.2.3-1.el7_0.x86_64.rpm │ │ ├── openssl-1.0.1e-34.el7_0.6.x86_64.rpm │ │ ├── perl-Error-0.17020-2.el7.noarch.rpm │ │ ├── perl-Git-1.8.3.1-4.el7.noarch.rpm │ │ ├── perl-TermReadKey-2.30-20.el7.x86_64.rpm │ │ ├── python-javapackages-3.4.1-6.el7_0.noarch.rpm │ │ ├── qemu-guest-agent-1.5.3-60.el7_0.11.x86_64.rpm │ │ ├── qemu-img-1.5.3-60.el7_0.11.x86_64.rpm │ │ ├── qemu-kvm-1.5.3-60.el7_0.11.x86_64.rpm │ │ ├── rsyslog-7.4.7-7.0.1.el7_0.x86_64.rpm │ │ ├── scl-utils-20130529-9.el7_0.x86_64.rpm │ │ ├── sos-3.0-23.0.2.el7_0.4.noarch.rpm │ │ ├── systemd-libs-208-11.0.1.el7_0.5.x86_64.rpm │ │ ├── systemd-python-208-11.0.1.el7_0.5.x86_64.rpm │ │ ├── tree-1.6.0-10.el7.x86_64.rpm │ │ ├── unzip-6.0-14.el7.x86_64.rpm │ │ ├── wpa_supplicant-2.0-13.el7_0.x86_64.rpm │ │ └── yum-utils-1.1.31-25.0.1.el7_0.noarch.rpm │ ├── primary.xml.gz │ ├── repomd.xml │ └── updateinfo.xml.gz ├── MySQL-56 │ ├── cachecookie │ ├── gen │ │ ├── other.xml │ │ ├── other.xml.sqlite │ │ ├── primary.xml │ │ ├── primary.xml.sqlite │ │ └── updateinfo.xml │ ├── other.xml.gz │ ├── packages │ ├── primary.xml.gz │ ├── repomd.xml │ └── updateinfo.xml.gz ├── OL7-Addons │ ├── cachecookie │ ├── gen │ │ ├── primary.xml │ │ ├── primary.xml.sqlite │ │ └── updateinfo.xml │ ├── packages │ │ └── docker-1.3.2-1.0.1.el7.x86_64.rpm │ ├── primary.xml.gz │ ├── repomd.xml │ └── updateinfo.xml.gz ├── Optional │ ├── cachecookie │ ├── gen │ │ ├── primary.xml │ │ ├── primary.xml.sqlite │ │ └── updateinfo.xml │ ├── packages │ ├── primary.xml.gz │ ├── repomd.xml │ └── updateinfo.xml.gz ├── SpaceWalker22 │ ├── cachecookie │ ├── filelists.xml.gz │ ├── gen │ │ ├── filelists.xml │ │ ├── filelists.xml.sqlite │ │ ├── other.xml │ │ ├── other.xml.sqlite │ │ ├── primary.xml │ │ ├── primary.xml.sqlite │ │ └── updateinfo.xml │ ├── other.xml.gz │ ├── packages │ │ └── rhnsd-5.0.14-1.el7.x86_64.rpm │ ├── primary.xml.gz │ ├── repomd.xml │ └── updateinfo.xml.gz ├── timedhosts ├── UEKR3 │ ├── cachecookie │ ├── gen │ │ ├── other.xml │ │ ├── other.xml.sqlite │ │ ├── primary.xml │ │ ├── primary.xml.sqlite │ │ └── updateinfo.xml │ ├── other.xml.gz │ ├── packages │ │ └── kernel-uek-firmware-3.8.13-55.1.2.el7uek.noarch.rpm │ ├── primary.xml.gz │ ├── repomd.xml │ └── updateinfo.xml.gz └── UEKR3-OFED20 ├── cachecookie ├── gen │ ├── other.xml │ ├── other.xml.sqlite │ ├── primary.xml │ ├── primary.xml.sqlite │ └── updateinfo.xml ├── other.xml.gz ├── packages ├── primary.xml.gz ├── repomd.xml └── updateinfo.xml.gz 23 directories, 124 files [root@oel7 software]# [root@oel7 software]# find yum/ -name "*.rpm" yum/x86_64/7Server/Latest/packages/initscripts-9.49.17-1.0.1.el7_0.1.x86_64.rpm yum/x86_64/7Server/Latest/packages/gnome-shell-extension-apps-menu-3.8.4-10.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/libvirt-client-1.1.1-29.0.1.el7_0.3.x86_64.rpm yum/x86_64/7Server/Latest/packages/glibc-headers-2.17-55.0.4.el7_0.3.x86_64.rpm yum/x86_64/7Server/Latest/packages/gnome-shell-extension-places-menu-3.8.4-10.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/scl-utils-20130529-9.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/libgomp-4.8.2-16.2.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/yum-utils-1.1.31-25.0.1.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/openssl-1.0.1e-34.el7_0.6.x86_64.rpm yum/x86_64/7Server/Latest/packages/iwl3160-firmware-22.0.7.0-35.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/qemu-img-1.5.3-60.el7_0.11.x86_64.rpm yum/x86_64/7Server/Latest/packages/systemd-libs-208-11.0.1.el7_0.5.x86_64.rpm yum/x86_64/7Server/Latest/packages/cups-filters-1.0.35-15.el7_0.1.x86_64.rpm yum/x86_64/7Server/Latest/packages/unzip-6.0-14.el7.x86_64.rpm yum/x86_64/7Server/Latest/packages/nss-3.16.2.3-2.0.1.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/NetworkManager-0.9.9.1-29.git20140326.4dba720.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/gnome-shell-extension-alternate-tab-3.8.4-10.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/systemd-python-208-11.0.1.el7_0.5.x86_64.rpm yum/x86_64/7Server/Latest/packages/mesa-filesystem-9.2.5-6.20131218.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/glibc-devel-2.17-55.0.4.el7_0.3.x86_64.rpm yum/x86_64/7Server/Latest/packages/sos-3.0-23.0.2.el7_0.4.noarch.rpm yum/x86_64/7Server/Latest/packages/iwl6000g2a-firmware-17.168.5.3-35.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/lzo-2.06-6.el7_0.2.x86_64.rpm yum/x86_64/7Server/Latest/packages/NetworkManager-config-server-0.9.9.1-29.git20140326.4dba720.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/iwl5000-firmware-8.83.5.1_1-35.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/libsmbclient-4.1.1-37.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/rsyslog-7.4.7-7.0.1.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/qemu-kvm-1.5.3-60.el7_0.11.x86_64.rpm yum/x86_64/7Server/Latest/packages/fprintd-0.5.0-4.0.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/qemu-guest-agent-1.5.3-60.el7_0.11.x86_64.rpm yum/x86_64/7Server/Latest/packages/gnutls-dane-3.1.18-10.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/wpa_supplicant-2.0-13.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/cups-filters-libs-1.0.35-15.el7_0.1.x86_64.rpm yum/x86_64/7Server/Latest/packages/gtk2-immodule-xim-2.24.22-5.el7_0.1.x86_64.rpm yum/x86_64/7Server/Latest/packages/python-javapackages-3.4.1-6.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/mesa-libgbm-9.2.5-6.20131218.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/mesa-libGL-9.2.5-6.20131218.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/nss-softokn-3.16.2.3-1.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/libvirt-daemon-1.1.1-29.0.1.el7_0.3.x86_64.rpm yum/x86_64/7Server/Latest/packages/libvirt-daemon-driver-secret-1.1.1-29.0.1.el7_0.3.x86_64.rpm yum/x86_64/7Server/Latest/packages/cyrus-sasl-plain-2.1.26-17.0.1.el7.x86_64.rpm yum/x86_64/7Server/Latest/packages/gdm-libs-3.8.4-28.0.1.el7_0.1.x86_64.rpm yum/x86_64/7Server/Latest/packages/dracut-network-033-161.el7_0.173.x86_64.rpm yum/x86_64/7Server/Latest/packages/kernel-headers-3.10.0-123.13.2.el7.x86_64.rpm yum/x86_64/7Server/Latest/packages/cronie-anacron-1.4.11-13.el7.x86_64.rpm yum/x86_64/7Server/Latest/packages/iwl2000-firmware-18.168.6.1-35.el7_0.noarch.rpm yum/x86_64/7Server/Latest/packages/gcc-4.8.2-16.2.el7_0.x86_64.rpm yum/x86_64/7Server/Latest/packages/git-1.8.3.1-4.el7.x86_64.rpm yum/x86_64/7Server/Latest/packages/perl-Error-0.17020-2.el7.noarch.rpm yum/x86_64/7Server/Latest/packages/perl-Git-1.8.3.1-4.el7.noarch.rpm yum/x86_64/7Server/Latest/packages/perl-TermReadKey-2.30-20.el7.x86_64.rpm yum/x86_64/7Server/Latest/packages/tree-1.6.0-10.el7.x86_64.rpm yum/x86_64/7Server/OL7-Addons/packages/docker-1.3.2-1.0.1.el7.x86_64.rpm yum/x86_64/7Server/SpaceWalker22/packages/rhnsd-5.0.14-1.el7.x86_64.rpm yum/x86_64/7Server/UEKR3/packages/kernel-uek-firmware-3.8.13-55.1.2.el7uek.noarch.rpm [root@oel7 software]# [root@oel7 software]# find yum/ -name "*.rpm" | wc -l 55 [root@oel7 software]# |
由于启用了YUM的本地缓存,这样,以后的安装与部署,你可以将上述的55个RPM包做成本地的YUM源,从而脱离外网。
在BtrFS安装完成后,需要关掉服务器,并添加新的一块虚拟磁盘,用于存放Docker的Container数据。
然后,启动虚拟机。
对存储介质的配置:
通过“mkfs.btrfs”,将新增的存储设为适合Docker的格式。
具体指令如下:
mkfs.btrfs /dev/sdb
你可以通过“blkid”验证上述“mkfs”是否执行成功:
1 2 3 |
[root@oel7 ~]# blkid /dev/sdb /dev/sdb: UUID="81a0e5a3-1ab5-4b51-9718-d3923f899995" UUID_SUB="bc6c0e3a-dc24-4a25-be9d-d80a327228b6" TYPE="btrfs" [root@oel7 ~]# |
你可以看到,它的“TYPE”值为:btrfs。
这里,需要记住的是UUID的值,该值在后续的操作中会被使用到。
创建文件:/etc/systemd/system/var-lib-docker.mount
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@oel7 ~]# cat /etc/systemd/system/var-lib-docker.mount [Unit] Description = Docker Image Store [Mount] What = UUID="81a0e5a3-1ab5-4b51-9718-d3923f899995" Where = /var/lib/docker Type = btrfs [Install] WantedBy = multi-user.target [root@oel7 ~]# |
上面,“[Mount]”中的“What”的UUID,即“blkid”命令反馈的UUID的值。
该文件的作用是,将拥有特定UUID的设备,挂载到/var/lib/docker的挂载点下。
即,如下效果:
1 2 3 4 5 6 7 8 9 10 11 |
[root@oel7 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ol-root 18G 5.4G 13G 31% / devtmpfs 986M 0 986M 0% /dev tmpfs 995M 148K 995M 1% /dev/shm tmpfs 995M 8.9M 986M 1% /run tmpfs 995M 0 995M 0% /sys/fs/cgroup /dev/sdb 20G 337M 18G 2% /var/lib/docker /dev/sr0 3.9G 3.9G 0 100% /iso /dev/sda1 497M 143M 354M 29% /boot [root@oel7 ~]# |
“df -h”中,你可以看到:
/dev/sdb 20G 337M 18G 2% /var/lib/docker
但,在刚刚编辑完:/etc/systemd/system/var-lib-docker.mount文件后,你不能立即看到如上的“df -h”的效果。
你还需要做一些设定:
1. 开机自动生效var-lib-docker.mount的设定
systemctl enable var-lib-docker
2. 立即生效(挂载)var-lib-docker.mount中的挂载策略
systemctl start var-lib-docker.mount
修改Docker的服务选项。
Docker的服务的配置文件:/etc/sysconfig/docker
1 2 3 4 5 6 7 8 |
[root@oel7 ~]# cat /etc/sysconfig/docker #OPTIONS=--selinux-enabled OPTIONS=-s btrfs #if you have WEB Proxy, Then Set below value for true value. #HTTP_PROXY="proxy_url:port" #HTTPS_PROXY="proxy_url:port" [root@oel7 ~]# |
如上所示,通过修改OPTIONS可以修改Docker启动时的选项设定,默认该处设定为:–selinux-enabled,需要将其修改为:-s btrfs。
因为,本例中,我们启用BtrFS类型的文件系统作为容器的存储。
另外,如果你有代理,可以设置:HTTP_PROXY或者HTTPS_PROXY。
复制文件docker.service,从:/usr/lib/systemd/system中,复制到:/etc/systemd/system中:
cp /usr/lib/systemd/system/docker.service /etc/systemd/system/docker.service
修改文件:/etc/systemd/system/docker.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[root@oel7 ~]# cat /etc/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=http://docs.docker.com Requires=var-lib-docker.mount After=network.target docker.socket Requires=docker.socket After=var-lib-docker.mount [Service] Type=notify EnvironmentFile=-/etc/sysconfig/docker EnvironmentFile=-/etc/sysconfig/docker-storage ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS $DOCKER_STORAGE_OPTIONS LimitNOFILE=1048576 LimitNPROC=1048576 [Install] WantedBy=multi-user.target [root@oel7 ~]# |
这样,至此,Docker的配置就基本上完成了。
下面对一些需要做一些做的额外的设定,进行说明。
开机启动Docker:
systemctl enable docker
立即启动Docker服务:
systemctl start docker
查看Docker的状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
[root@oel7 ~]# systemctl status docker docker.service - Docker Application Container Engine Loaded: loaded (/etc/systemd/system/docker.service; enabled) Active: active (running) since Tue 2014-12-23 17:10:42 CST; 5h 32min ago Docs: http://docs.docker.com Main PID: 2218 (docker) CGroup: /system.slice/docker.service └─2218 /usr/bin/docker -d -H fd:// -s btrfs Dec 23 20:56:44 oel7 docker[2218]: [3f8ca5c2] -job images() = OK (0) Dec 23 20:57:22 oel7 docker[2218]: [info] POST /v1.15/images/load Dec 23 20:57:22 oel7 docker[2218]: [3f8ca5c2] +job load() Dec 23 20:57:28 oel7 docker[2218]: [3f8ca5c2] +job image_get(d56e767abb61011f8f2cf1c3d419a09163939fa2491ac132...c0b12) Dec 23 20:57:28 oel7 docker[2218]: No such id: d56e767abb61011f8f2cf1c3d419a09163939fa2491ac132e0de86f5985c0b12 Dec 23 20:57:28 oel7 docker[2218]: [3f8ca5c2] -job image_get(d56e767abb61011f8f2cf1c3d419a09163939fa2491ac132...RR (1) Dec 23 20:57:43 oel7 docker[2218]: [3f8ca5c2] -job load() = OK (0) Dec 23 20:57:47 oel7 docker[2218]: [info] GET /v1.15/images/json Dec 23 20:57:47 oel7 docker[2218]: [3f8ca5c2] +job images() Dec 23 20:57:47 oel7 docker[2218]: [3f8ca5c2] -job images() = OK (0) Hint: Some lines were ellipsized, use -l to show in full. [root@oel7 ~]# [root@oel7 ~]# |
以上的状态是通过Linux的命令获得的。
Docker自己的命令查看状态与相关的信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@oel7 ~]# docker version Client version: 1.3.2 Client API version: 1.15 Go version (client): go1.3.3 Git commit (client): 4e9bbfa/1.3.2 OS/Arch (client): linux/amd64 Server version: 1.3.2 Server API version: 1.15 Go version (server): go1.3.3 Git commit (server): 4e9bbfa/1.3.2 [root@oel7 ~]# [root@oel7 ~]# docker info Containers: 0 Images: 4 Storage Driver: btrfs Execution Driver: native-0.2 Kernel Version: 3.8.13-35.3.1.el7uek.x86_64 Operating System: Oracle Linux Server 7.0 [root@oel7 ~]# |
至此,Docker在Oracle Enterprise Linux 7上的安装,就完成了。
————————————————————————————
Finished。