docker compose up 抛出错误 “stat [compose.yaml]: 没有该文件或目录”

huangapple go评论56阅读模式
英文:

docker compose up throws an error "stat [compose.yaml]: no such file or directory"

问题

在Ubuntu 23.04(GNU/Linux 6.2.0-24-generic x86_64)上运行Docker Compose时遇到了错误。

$ sudo docker compose -f /containers/watchtower/watchtower.yaml up -d
stat /containers/watchtower/watchtower.yaml: no such file or directory

compose.yaml 存在。

$ ls -l /containers/watchtower/watchtower.yaml
-rwxr-xr-x 1 bob bob 1373 Jul 10 21:39 /containers/watchtower/watchtower.yaml
$ stat /containers/watchtower/watchtower.yaml
  文件:/containers/watchtower/watchtower.yaml
  大小:1373       块:8          IO块:4096   普通文件
设备:0,29  i节点:117329      硬链接:1
访问:(0755/-rwxr-xr-x)  用户ID:(1000/   bob)   组ID:(1000/   bob)
访问:2023-07-10 21:47:36.158533071 +0000
修改:2023-07-10 21:39:20.331301456 +0000
更改:2023-07-10 21:39:20.331301456 +0000
创建:2023-07-10 21:39:20.331301456 +0000

一些背景信息:

$ docker compose version
Docker Compose版本v2.17.2
$ python3 --version
Python 3.11.2
$ uname -r
6.2.0-24-generic
$ cat /containers/watchtower/watchtower.yaml
---
version: "3.8"
services:
  watchtower:
    image: containrrr/watchtower:latest
    container_name: watchtower
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - TZ=Europe/London
      - WATCHTOWER_CLEANUP=true
      - WATCHTOWER_INCLUDE_STOPPED=true
      - WATCHTOWER_REVIVE_STOPPED=false
      - WATCHTOWER_LABEL_ENABLE=false
      - WATCHTOWER_MONITOR_ONLY=false
      - WATCHTOWER_TIMEOUT=300
      - WATCHTOWER_SCHEDULE=0 16 2 * * *

有人可以给我指点一下出了什么问题吗?

英文:

On ubuntu 23.04 (GNU/Linux 6.2.0-24-generic x86_64), I have encountered an error while trying to run docker compose.

$ sudo docker compose -f /containers/watchtower/watchtower.yaml up -d
stat /containers/watchtower/watchtower.yaml: no such file or directory

The compose.yaml exists.

$ ls -l /containers/watchtower/watchtower.yaml 
-rwxr-xr-x 1 bob bob 1373 Jul 10 21:39 /containers/watchtower/watchtower.yaml
$ stat /containers/watchtower/watchtower.yaml 
  File: /containers/watchtower/watchtower.yaml
  Size: 1373      	Blocks: 8          IO Block: 4096   regular file
Device: 0,29	Inode: 117329      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   bob)   Gid: ( 1000/   bob)
Access: 2023-07-10 21:47:36.158533071 +0000
Modify: 2023-07-10 21:39:20.331301456 +0000
Change: 2023-07-10 21:39:20.331301456 +0000
 Birth: 2023-07-10 21:39:20.331301456 +0000

some background info

$ docker compose version
Docker Compose version v2.17.2
$ python3 --version
Python 3.11.2
$ uname -r
6.2.0-24-generic
$ cat /containers/watchtower/watchtower.yaml 
---
version: "3.8"
services:
  watchtower:
    image: containrrr/watchtower:latest
    container_name: watchtower
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - TZ=Europe/London
      - WATCHTOWER_CLEANUP=true
      - WATCHTOWER_INCLUDE_STOPPED=true
      - WATCHTOWER_REVIVE_STOPPED=false
      - WATCHTOWER_LABEL_ENABLE=false
      - WATCHTOWER_MONITOR_ONLY=false
      - WATCHTOWER_TIMEOUT=300
      - WATCHTOWER_SCHEDULE=0 16 2 * * *

Could someone give me a pointer on what goes wrong?

答案1

得分: 1

我已经找出问题所在。

我是通过 snap 安装的 Docker。

一旦我用本地版本替换了 snap 版本,docker compose 就可以正常工作。

英文:

I have found out what the problem was.

I had installed docker through snap.

docker compose works once I have replaced the snap version with the native version.

huangapple
  • 本文由 发表于 2023年7月11日 05:53:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76657566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定