Run Docker1.12.0 on CentOS 7 to modify the default file system of Docker to overlay or aufs.

Source: Internet
Author: User
Tags centos iptables


In CentOS Docker, the default file system is devicemapper, but this seems a bit bad, what's worse is that the official website of DC/OS explains that unknown issue will appear and Docker cannot be run in Docker, by default, DeviceMapper creates a loop-lvm to build the snapshots of images and containers. However, in the production environment, Docker officially recommends using directly connected lvm volumes to build images and containers, and then loading them using the following method when starting Docker Daemon:

{
"Storage-driver": "devicemapper ",
"Storage-opts": ["dm. thinpooldev =/dev/mapper/docker-thinpool", "dm. use_deferred_removal = true"
     ]
 }

The following is what CentOS looks like after it is started by default.


[Root @ DS-VM-Node200 ~] # Docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.12.0
Storage Driver: devicemapper
Pool Name: docker-253: 3-16797760-pool
Pool Blocksize: 65.54 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file:/dev/loop0
Metadata file:/dev/loop1
Data Space Used: 11.8 MB
Data Space Total: 107.4 GB
Data Space Available: 10.68 GB
Metadata Space Used: 581.6 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Thin Pool Minimum Free Space: 10.74 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/data
WARNING: Usage of loopback devices is stronugly discouraged for production use. Use '-- storage-opt dm. thinpooldev' to specify a custom block storage device.
Metadata loop file:/var/lib/docker/devicemapper/metadata
Library Version: 1.02.107-RHEL7 (2015-10-14)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-327. el7.x86 _ 64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.451 GiB
Name: DS-VM-Node200.cluster.com
ID: 2DEU: CRW4: 4GFU: 47F6: ROAV: QZ43: H4L3: YBH7: UO24: YA3Y: GMBA: 7ZEA
Docker Root Dir:/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
[Root @ DS-VM-Node200 ~] #


Let's first modify it to OverlayFS's default file system.


[Root @ DS-VM-Node200 ~] # Echo "overlay">/etc/modules-load.d/overlay. conf
[Root @ DS-VM-Node200 ~] # Cat/proc/modules | grep overlay
[Root @ DS-VM-Node200 ~] # Reboot # restart the system to make the modification take effect


[Root @ DS-VM-Node200 ~] # Mkdir-p/etc/systemd/system/docker. service. d
[Root @ DS-VM-Node200 ~] # Cat>/etc/systemd/system/docker. service. d/docker_boot.conf <-EOF
[Service]
ExecStart =
ExecStart =/usr/bin/docker daemon-D-s overlay
EOF
[Root @ DS-VM-Node200 ~] # Cat/etc/systemd/system/docker. service. d/docker_boot.conf
[Service]
ExecStart =/usr/bin/docker daemon-D-s overlay
[Root @ DS-VM-Node200 ~] #


[Root @ DS-VM-Node200 ~] # Systemctl daemon-reload
[Root @ DS-VM-Node200 ~] # Systemctl start docker. service
[Root @ DS-VM-Node200 ~] # Docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.12.0
Storage Driver: overlay
Backing Filesystem: xfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: overlay bridge null host
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-327. el7.x86 _ 64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.451 GiB
Name: DS-VM-Node200.cluster.com
ID: 2DEU: CRW4: 4GFU: 47F6: ROAV: QZ43: H4L3: YBH7: UO24: YA3Y: GMBA: 7ZEA
Docker Root Dir:/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 15
Goroutines: 22
System Time: 2016-08-10T23: 55: 20.643632194 + 08: 00
EventsListeners: 0
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
[Root @ DS-VM-Node200 ~] #


Next we will modify it to aufs. Here we need to replace the kernel with the kernel compiled on this site. (The kernel source supports CentOS 6 CentOS7)


[Root @ DS-VM-Node200 ~] # Curl-Lks http://mirrors.dwhd.org/kernel-ml-aufs/kernel-ml-auf.repo>/etc/yum. repos. d/kernel-ml-aufs.repo
[Root @ DS-VM-Node200 ~] # Yum-y remove kernel-headers kernel-tools-libs
[Root @ DS-VM-Node200 ~] # Yum-y install kernel-ml-aufs-headers kernel-ml-aufs-devel kernel-ml-aufs-tools-libs-devel perf
[Root @ DS-VM-Node200 ~] # Awk-F \ ''$1 =" menuentry "{print $2} '/etc/grub2.cfg
CentOS Linux (4.7.0-1. el7.centos. x86_64) 7 (Core)
CentOS Linux (3.10.0-327. el7.x86 _ 64) 7 (Core)
CentOS Linux (0-rescue-c164c19fb49d4b4aa3a60f1bd6ac6a8c) 7 (Core)
[Root @ DS-VM-Node200 ~] # Grub2-set-default 0 # set 0 to start
[Root @ DS-VM-Node200 ~] # Sed-I '/\ [main \]/a exclude = kernel *'/etc/yum. conf
[Root @ DS-VM-Node200 ~] # Reboot


[Root @ DS-VM-Node200 ~] # Cat/proc/version
Linux version 4.7.0-1. el7.centos. x86_64 (mockbuild@DT-VM-Node169.cluster.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) #1 SMP Fri Jul 29 05:38:16 CST 2016
[Root @ DS-VM-Node200 ~] # Cat>/etc/systemd/system/docker. service. d/docker_boot.conf <-EOF
[Service]
ExecStart =
ExecStart =/usr/bin/docker daemon-D-s aufs
EOF
[Root @ DS-VM-Node200 ~] # Systemctl daemon-reload
[Root @ DS-VM-Node200 ~] # Systemctl start docker. service
[Root @ DS-VM-Node200 ~] # Docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.12.0
Storage Driver: aufs
Root Dir:/var/lib/docker/aufs
Backing Filesystem: xfs
Dirs: 0
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge null host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.7.0-1. el7.centos. x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.858 GiB
Name: DS-VM-Node200.cluster.com
ID: 2DEU: CRW4: 4GFU: 47F6: ROAV: QZ43: H4L3: YBH7: UO24: YA3Y: GMBA: 7ZEA
Docker Root Dir:/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 14
Goroutines: 22
System Time: 2016-08-11T00: 07: 19.40686965 + 08: 00
EventsListeners: 0
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
[Root @ DS-VM-Node200 ~] #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.