【问题标题】:Mount volume with docker-compose has incorrect format使用 docker-compose 挂载卷的格式不正确
【发布时间】:2021-11-04 08:25:40
【问题描述】:

我正在学习 docker 和 docker compose,当我尝试运行 docker-compose up 时遇到了下一个问题。

让我看看我的docker-compose.yml

services:
  proxy:
    image: nginx
    ports:
      - '80:80'
    volumes:
      - ./nginx.conf:/etc/ningx/conf.d/default.conf:ro

这是我面临的错误:

nginx.conf:/etc/ningx/conf.d/default.conf:ro has incorrect format, should be external:internal[:mode]

我尝试过的事情:

我遇到了这个question,但我尝试了版本标签中提到的内容,但得到了类似的输出。

我检查了文档,一切看起来都很好。

我有最新版本:

Client: Docker Engine - Community
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:54:27 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:33 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

文件nginx.conf 存在,我正在从正确的目录启动命令。

【问题讨论】:

  • 嗯,我看到一个小错字,除非你是在打字,否则这可能是你的问题。第二部分,/etc/ningx/conf.d/default.conf,说ningx,它可能不存在,应该是etc/nginx/conf.d/default.conf

标签: docker docker-compose volumes


【解决方案1】:

好吧,在尝试了更多的东西之后,我最终找到了问题所在。问题是这些文件所在的绝对路径包含一个分号:

基本上,这是来自 udemy 课程,我将父文件夹命名为课程名称。

我会删除这个问题,但也许它可以在将来对某人有所帮助。

谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-10
    • 2017-04-09
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多