docker問題解決
啟動daemon命令取決與你使用的作業系統:
RHEL, CentOS, Fedora, Ubuntu 16.04 或者更高版本,使用systemd管理docker服務啟動。
$ sudo systemctl enable docker
1
關閉自動啟動
$ sudo systemctl disable docker
1
手動啟動daemon
$ dockerd
我們可以執行以下命令把當前使用者加入到docker組,避免每次docker命令都要sudo。
$ sudo usermod -aG docker username
Docker daemon配置
加速器:針對Docker客戶端版本大於1.10的使用者,您可以通過修改daemon配置檔案/etc/docker/daemon.json來使用加速器:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://5162s31v.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
daemon包含很多配置選項,在手工啟動daemon的時候可以通過flags配置daemon啟動引數,或者通過daemon.json配置檔案更改配置。
完整的daemon.json的啟動引數如下:
{
"api-cors-header": "",
"authorization-plugins": [],
"bip": "",
"bridge": "",
"cgroup-parent": "",
"cluster-store": "",
"cluster-store-opts": {},
"cluster-advertise": "",
"debug": true,
"default-gateway": "",
"default-gateway-v6": "",
"default-runtime": "runc",
"default-ulimits": {},
"disable-legacy-registry": false,
"dns": [],
"dns-opts": [],
"dns-search": [],
"exec-opts": [],
"exec-root": "",
"fixed-cidr": "",
"fixed-cidr-v6": "",
"graph": "",
"group": "",
"hosts": [],
"icc": false,
"insecure-registries": [],
"ip": "0.0.0.0",
"iptables": false,
"ipv6": false,
"ip-forward": false,
"ip-masq": false,
"labels": [],
"live-restore": true,
"log-driver": "",
"log-level": "",
"log-opts": {},
"max-concurrent-downloads": 3,
"max-concurrent-uploads": 5,
"mtu": 0,
"oom-score-adjust": -500,
"pidfile": "",
"raw-logs": false,
"registry-mirrors": [],
"runtimes": {
"runc": {
"path": "runc"
},
"custom": {
"path": "/usr/local/bin/my-runc-replacement",
"runtimeArgs": [
"--debug"
]
}
},
"selinux-enabled": false,
"storage-driver": "",
"storage-opts": [],
"swarm-default-advertise-addr": "",
"tls": true,
"tlscacert": "",
"tlscert": "",
"tlskey": "",
"tlsverify": true,
"userland-proxy": false,
"userns-remap": ""
}
更好的方法是把這些啟動引數寫道配置檔案中:daemon.json