简体   繁体   English

我怎么知道“ init”还是“ systemd”控制着码头工人?

[英]How do I know whether “init” or “systemd” controls the docker?

I follow the official document to install Docker on Ubuntu 16.04 LTS . 我遵循官方文档Ubuntu 16.04 LTS上安装Docker Since my server works behind proxy, so I need to configure proxy for Docker. 由于我的服务器在代理后面工作,因此我需要为Docker配置代理。 The processes running on my host like this: 在主机上运行的进程如下:

# 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

Since docker 's father process is init , I modify the /etc/default/docker file: 由于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/"
......

But unfortunately, this change doesn't take effect. 但不幸的是,此更改没有生效。 I doubt the Docker is controlled by systemd , so I check it: 我怀疑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
......

Then I follow this post to set proxy, now it works! 然后,我按照此帖子设置代理,现在可以使用了!

Per my understanding, since this docker process is spawned by init , it should be controlled by it. 据我了解,由于此docker进程是由init产生的,因此应由它控制。 But in reality, it seems controlled by systemd . 但实际上,它似乎是由systemd控制的。 How do I know whether init or systemd controls the docker ? 我怎么知道init还是systemd控制着docker

On Ubuntu 16.04, /sbin/init is systemd. 在Ubuntu 16.04上, /sbin/init systemd。 You can confirm that the binary is provided by the systemd-sysv package: 您可以确认二进制文件是由systemd-sysv软件包提供的:

dpkg -L systemd-sysv | grep /sbin/init 

Further, 'init' is just a symlink to systemd: 此外,“ init”只是到systemd的符号链接:

$ ls -lthd /sbin/init
lrwxrwxrwx 1 root root 20 May 12 05:39 /sbin/init -> /lib/systemd/systemd   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM