我按照官方document在Docker
上安装Ubuntu 16.04 LTS
。由于我的服务器在代理之后工作,所以我需要为Docker配置代理。在我的主机上运行的进程如下:
# ps -aef | grep init
root 1 0 0 03:05 ? 00:00:01 /sbin/init
# ps -aef | grep docker
root 3223 1 0 04:04 ? 00:00:00 /usr/bin/docker daemon -H fd://
root 3230 3223 0 04:04 ? 00:00:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc --start-timeout 2m
由于docker
的父进程为init
,我修改了/etc/default/docker
文件:
# cat /etc/default/docker
# Docker Upstart and SysVinit configuration file
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
# Please see the documentation for "systemd drop-ins":
# https://docs.docker.com/engine/articles/systemd/
#
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
# If you need Docker to use an HTTP proxy, it can also be specified here.
export http_proxy="http://web-proxy.corp.xxxxxx.com:8080/"
export https_proxy="https://web-proxy.corp.xxxxxx.com:8080/"
......
但遗憾的是,这一变化并未生效。我怀疑Docker
是否由systemd
控制,所以我检查一下:
# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2016-07-14 03:19:35 EDT; 2min 16s ago
Docs: https://docs.docker.com
Main PID: 3057 (docker)
Tasks: 24
Memory: 25.2M
CPU: 531ms
CGroup: /system.slice/docker.service
├─3057 /usr/bin/docker daemon -H fd://
└─3064 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc --start-timeout 2m
......
然后我按照post设置代理,现在可以了!
根据我的理解,由于此docker
进程由init
生成,因此应由它控制。但实际上,它似乎由systemd
控制。我如何知道init
或systemd
是否会控制docker
?
答案 0 :(得分:1)
在Ubuntu 16.04上,/sbin/init
是 systemd。您可以确认二进制文件是由systemd-sysv
包提供的:
dpkg -L systemd-sysv | grep /sbin/init
此外,' init'只是systemd的符号链接:
$ ls -lthd /sbin/init
lrwxrwxrwx 1 root root 20 May 12 05:39 /sbin/init -> /lib/systemd/systemd