docker 基础设置

Posted by 小炒肉 on January 1, 2016

docker 基础

docker install

1
2
3
# 官网安装
wget -qO- https://get.docker.com/ | sh

docker 设置

1
2
3
4
5
6
7
8
9
10
# 第一种方式 修改 /lib/systemd/system/docker.service


ExecStart=/usr/bin/dockerd 

# 修改为

ExecStart=/usr/bin/dockerd --graph=/opt/docker --registry-mirror=http://b438f72b.m.daocloud.io --iptables=false


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
# 第二种方式,增加 opts

mkdir -p /etc/systemd/system/docker.service.d/


# 增加 docker.service 文件

cat >> /etc/systemd/system/docker.service << EOF

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker-storage-setup.service
Wants=docker-storage-setup.service

[Service]
Type=notify
Environment=GOTRACEBACK=crash
ExecReload=/bin/kill -s HUP $MAINPID
Delegate=yes
KillMode=process
ExecStart=/usr/bin/docker daemon \
          $DOCKER_OPTS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $DOCKER_DNS_OPTIONS \
          $INSECURE_REGISTRY
TasksMax=infinity
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=1min
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
EOF



# 增加配置文件

cat >> /etc/systemd/system/docker.service.d/docker-options.conf << EOF
[Service]
Environment="DOCKER_OPTS=--graph=/opt/docker --registry-mirror=http://b438f72b.m.daocloud.io --iptables=false"
EOF