大网数据广告活动
服务器运维问答

Why does docker-compose issue a "No such file or directory" when the file is there?

· 52CE 我爱测

I am testing a bare metal recovery of my server which basically starts a set of docker container with my services. I recovered from a backup /etc/docker , where I keep all the configuration and persistent volumes. I then tried to…

问题原文

原帖链接 · WoJ · CC BY-SA 4.0

I am testing a bare metal recovery of my server which basically starts a set of docker container with my services. I recovered from a backup /etc/docker, where I keep all the configuration and persistent volumes.

I then tried to start one of the containers:

root@srv-backup:/etc/docker# docker-compose --verbose -f /etc/docker/docker-compose.d/20-registry.yaml up
compose.config.config.find: Using configuration files: /etc/docker/docker-compose.d/20-registry.yaml
ERROR: compose.cli.main.main: .IOError: [Errno 2] No such file or directory: '/etc/docker/docker-compose.d/20-registry.yaml'

The file is however there:

root@srv-backup:/# ll /etc/docker/docker-compose.d/20-registry.yaml
-rwxrwxr-x+ 1 root root 842 Jan 24 15:19 /etc/docker/docker-compose.d/20-registry.yaml*

root@srv-backup:/# cat /etc/docker/docker-compose.d/20-registry.yaml
services:
  registry:
    container_name: registry
    image: registry
    labels:
      - traefik.http.routers.registry.rule=Host(`registry.example.com`)
      - traefik.http.routers.registry.entryPoints=https
      - traefik.http.routers.registry.tls=true
      - traefik.http.routers.registry.tls.certresolver=le
      - traefik.http.middlewares.lan.ipwhitelist.sourcerange=192.168.10.0/24, 192.168.20.0/24
      - traefik.http.routers.registry.middlewares=lan
      - traefik.enable=true
    restart: unless-stopped
    volumes:
      - /etc/docker/container-data/registry:/var/lib/registry
version: '3'

root@srv-backup:/# file /etc/docker/container-data/registry
/etc/docker/container-data/registry: directory

I tried all kind of incantations with relative and full paths - the issue is the same.

I was wondering whether the docker daemon has access to the file, but it also runs as root:

root@srv-backup:/# ps -ef | grep docker
root      2048     1  0 10:58 ?        00:00:08 dockerd -G docker --exec-root=/var/snap/docker/423/run/docker --data-root=/var/snap/docker/common/var-lib-docker --pidfile=/var/snap/docker/423/run/docker.pid --config-file=/var/snap/docker/423/config/daemon.json
root      2200  2048  0 10:58 ?        00:00:07 containerd --config /var/snap/docker/423/run/docker/containerd/containerd.toml --log-level error

I am quite at loss why it does not work (the docker file works correctly on the server I am trying to replicate in this DRP exercise)

已采纳解答

原帖链接 · WoJ · CC BY-SA 4.0

I found a workaround (this is not exactly an answer to the problem, but allows to go forward).

  1. I uninstalled the docker snap installation: snap remove docker
  2. I installed docker from the repositories: apt install docker.io
  3. I installed docker-compose:
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Now the command I used to start the example container works.

There must be something special with the snap version of docker.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-03-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。