如何在只读主机文件系统上运行docker daemon

问题描述 投票:0回答:1

我有一个在只读根分区上运行Ubuntu 16.04.6 LTS的Raspberry Pi 3。现在,我尝试启动docker守护程序。但是重启后会显示:

ubuntu@z11:~$ docker info
Client:
 Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

当尝试重新启动docker守护程序时,我得到:

ubuntu@z11:~$ sudo systemctl daemon-reload
ubuntu@z11:~$ sudo systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

这是systemctl status docker.service的输出:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: start-limit-hit) since Thu 2016-02-11 17:28:26 CET; 14s ago
     Docs: https://docs.docker.com
  Process: 1620 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 1620 (code=exited, status=1/FAILURE)

Feb 11 17:28:24 z11 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Feb 11 17:28:24 z11 systemd[1]: Failed to start Docker Application Container Engine.
Feb 11 17:28:24 z11 systemd[1]: docker.service: Unit entered failed state.
Feb 11 17:28:24 z11 systemd[1]: docker.service: Failed with result 'exit-code'.
Feb 11 17:28:26 z11 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Feb 11 17:28:26 z11 systemd[1]: Stopped Docker Application Container Engine.
Feb 11 17:28:26 z11 systemd[1]: docker.service: Start request repeated too quickly.
Feb 11 17:28:26 z11 systemd[1]: Failed to start Docker Application Container Engine.
Feb 11 17:28:26 z11 systemd[1]: docker.service: Unit entered failed state.
Feb 11 17:28:26 z11 systemd[1]: docker.service: Failed with result 'start-limit-hit'.

这是我的/ etc / fstab,具有只读的根分区,并且可读写/ var / lib / docker:

proc            /proc                   proc    defaults                                     0 0
/dev/mmcblk0p1  /boot                   vfat    ro                                           0 0
/dev/mmcblk0p2  /                       ext4    noatime,ro                                   0 0
/dev/mmcblk0p3  none                    swap    sw                                           0 0
/dev/mmcblk0p4  /var/lib/docker         ext4    noatime,rw                                   0 0
tmpfs           /var/log                tmpfs   defaults,noatime,nosuid,mode=0755,size=50m   0 0
tmpfs           /var/log/apache2        tmpfs   defaults,noatime,size=10m                    0 0
tmpfs           /var/lib/sudo           tmpfs   defaults,noatime,nosuid,mode=0755,size=2m    0 0
tmpfs           /tmp                    tmpfs   defaults,noatime,mode=1777,size=30m          0 0

[将根分区从ro更改为rw时,重新引导系统后docker运行良好。

如何使docker在保持根分区只读的情况下运行?docker是否需要写入其他文件或目录?

docker ubuntu raspberry-pi filesystems
1个回答
0
投票

显然,/ run(又名/ var / run)将用于打开套接字文件。 Docker是一个系统守护程序,“ docker”命令只是将输入发送到套接字文件。基本上,您已经将/ var的某些子目录挂载为rw,但未将/ var / run挂载。

如果您想将/ var / lib / docker保留在持久性存储上,那么重新配置docker.service可能也是一个更好的主意-可能要检查/ etc / sysconfig / docker并进行设置

DOCKER_OPTS="-g /data/docker"
© www.soinside.com 2019 - 2024. All rights reserved.