【问题标题】:What starts this docker process on my laptop?是什么在我的笔记本电脑上启动了这个 docker 进程?
【发布时间】:2017-05-23 20:29:05
【问题描述】:

每次我启动 Lubuntu 16.04 笔记本电脑时,我都会看到我有一个正在运行的 docker 容器:

$ ps -ef | grep docker
root      1724     1  3 21:17 ?        00:01:30 /usr/bin/dockerd -H fd://
root      1774  1724  0 21:17 ?        00:00:04 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root      4750  1774  0 21:17 ?        00:00:00 docker-containerd-shim 72541a4648b890132985daf2357d1130b8b5208cf12ede607b93ab2987629719 /var/run/docker/libcontainerd/72541a4648b890132985daf2357d1130b8b5208cf12ede607b93ab2987629719 docker-runc
stephane 10755  1793  0 22:07 pts/0    00:00:00 grep docker

它在端口 80 上为 Jenkins 应用程序提供服务,并在浏览器中请求 localhost/ 重定向到 http://localhost/login?from=%2F 并显示 Jenkins 警告页面:

Unlock Jenkins
To ensure Jenkins is securely set up by the administrator, a password has been written to the log (not sure where to find it?) and this file on the server:

一个 wget 请求显示:

$ wget localhost/
--2017-05-23 22:09:55--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2017-05-23 22:09:55 ERROR 403: Forbidden.

我如何知道哪个服务正在启动这个 docker 进程?

我查看了/etc/init.d/ 目录:

$ l /etc/init.d/
alsa-utils*  checkroot-bootclean.sh*  halt*   mattermostd*    nginxd*        rc*      single*    uuidd*
anacron*   checkroot.sh*      hostname.sh*  mountall-bootclean.sh*  ntp*         rc.local*    skeleton     whoopsie*
apachedsd*   console-setup*     httpd*  mountall.sh*    ondemand*      rcS*     ssh*     x11-common*
apparmor*  cron*        hwclock.sh* mountdevsubfs.sh* openvpn*       README     tomcatd*
apport*    cups*        irqbalance* mountkernfs.sh*   php-fpm*       reboot*      udev*
avahi-daemon*  cups-browsed*      keyboardd*  mountnfs-bootclean.sh*  plymouth*      redis*     ufw*
bluetooth*   dbus*        killprocs*  mountnfs.sh*    plymouth-log*  resolvconf*  umountfs*
bootmisc.sh*   docker*      kmod*   mysqld*     postfix*       rsync*     umountnfs.sh*
cgroupfs-mount*  dropboxd*      lightdm*  networking*   pppd-dns*      rsyslog*     umountroot*
checkfs.sh*  grub-common*     mariadbd* network-manager*  procps*        sendsigs*    urandom*

/etc/init.d/docker 是我的,将其从目录中删除,重新启动仍然会出现一个正在运行的 docker 进程。

我删除了/etc/init.d/docker文件,重启,有一个docker进程:

$ ps -ef | grep docker
root      1560     1  5 22:15 ?        00:00:06 /usr/bin/dockerd -H fd://
root      1645  1560  0 22:15 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root      4644  1645  0 22:15 ?        00:00:00 docker-containerd-shim 069db46cca05d43c35f05ff50aaa836507cbf69e4e3d9443b6b859d0edb5b076 /var/run/docker/libcontainerd/069db46cca05d43c35f05ff50aaa836507cbf69e4e3d9443b6b859d0edb5b076 docker-runc
stephane  5520  1741  0 22:17 pts/0    00:00:00 grep docker

所以我在所有这些文件中查找了任何 docker 文件,但没有找到任何名为 docker 的文件:

$ cd /etc/init.d/
[stephane@stephane-ThinkPad-X301 init.d]
$ grep.sh docker
[stephane@stephane-ThinkPad-X301 init.d]

每次我启动笔记本电脑时,都会出现这个 docker 进程,即使在离线时也是如此。

什么会启动这个 docker 进程?

【问题讨论】:

  • 在终端运行systemctl的结果是什么?
  • SO 是针对编程问题,而不是关于使用或配置 Linux 的问题。 SuperUser.com 或 unix.stackexchange.com 会更好地解决此类问题。
  • @OluwafemiSule 有相当大的输出。有什么具体的想法吗?

标签: linux ubuntu docker jenkins


【解决方案1】:

Lubuntu 16.04 带有default 的 systemd。在某些时候,您一定已经在 docker 中启动了一个 jenkins 实例 - 很难准确地说出最初是什么开始该过程的。但是,systemd 将是当前导致它启动的原因。为了阻止它运行,请运行以下命令:

systemctl status docker systemctl认为docker正在运行。

它可能会显示如下内容:

● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2017-05-21 22:59:46 EDT; 1 day 17h ago Docs: http://docs.docker.com Main PID: 1314 (dockerd-current) Tasks: 14 (limit: 8192) CGroup: /system.slice/docker.service └─1314 /usr/bin/dockerd-current --add-runtime oci=/usr/libexec/docker/docker-runc-current --default-runtime=oci --containerd /run/containerd.sock --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --selinux-enabled --log-driver=journald

要停止它,请运行systemctl stop docker,然后运行systemctl disable docker。如果这不起作用,作为最后的手段,您可以运行systemctl mask docker

【讨论】:

    【解决方案2】:

    Docker 正在您的环境中由 systemd 启动。您可以通过运行禁用整个引擎:

    sudo systemctl disable docker
    sudo systemctl stop docker
    

    您也可以只停止正在运行的容器(shim 和 Jenkins 应用程序):

    sudo docker ps # lists the running containers along with their container id
    sudo docker update --restart=no $container_id
    sudo docker stop $container_id
    

    如果你知道你不需要这个容器并且想要永久删除它,你可以运行这个而不是上面最后两个命令:

    sudo docker rm -f $container_id
    

    如果容器当前正在运行,-f 开关也会停止容器。


    编辑:根据您的评论,您的容器正在重新部署它的集群模式下运行。要停止它,首先找到正在运行它的堆栈或服务。

    sudo docker stack ls
    sudo docker service ls
    

    如果您看到列出的堆栈,您可以使用以下命令将其删除:

    sudo docker stack rm $stack_name
    

    如果没有列出堆栈,或者它们不适用于此容器,您可以删除服务:

    sudo docker service rm $service_name
    

    【讨论】:

    • 我尝试了--restart=norm -f 以及stop docker 命令,但容器总是在一个新的随机名称下重新创建,例如jenkins-master.1.j5btxg6hbznn07smp2hczb551。似乎有一个进程在每次停止和删除jenkins:latest 图像时生成一个新容器。
    • @Stephane 我已经更新了我的答案以涵盖 swarm 模式,该模式使容器具有这样的名称。
    • 移除swarm mode服务解决:$ docker service rm jenkins-master.
    猜你喜欢
    • 1970-01-01
    • 2020-01-26
    • 1970-01-01
    • 2020-09-27
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多