Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:撰写文件'/docker compose.yml';无效,因为:services.jenkins.volumes包含无效类型,它应该是数组_Docker_Docker Compose - Fatal编程技术网

错误:撰写文件'/docker compose.yml';无效,因为:services.jenkins.volumes包含无效类型,它应该是数组

错误:撰写文件'/docker compose.yml';无效,因为:services.jenkins.volumes包含无效类型,它应该是数组,docker,docker-compose,Docker,Docker Compose,docker compose文件如下所示: version: '3' services: jenkins: container_name: jenkins image: jenkins/jenkins ports: - "8080:8080" volumes: -$PWD/jenkins_home: /var/jenkins_home networks: - net networks: net

docker compose
文件如下所示:

version: '3'
services:
  jenkins:
    container_name: jenkins
    image: jenkins/jenkins
    ports:
      - "8080:8080"
    volumes:
      -$PWD/jenkins_home: /var/jenkins_home
    networks:
      - net
networks:
  net:
volumes:
    - /path/to/jenkins_home:/var/jenkins_home
docker版本信息:

Client: Docker Engine - Community
Version:           20.10.5
API version:       1.41
Go version:        go1.13.15
Git commit:        55c4c88
Built:             Tue Mar  2 20:33:55 2021
OS/Arch:           linux/amd64
Context:           default
Experimental:      true

Server: Docker Engine - Community
Engine:
 Version:          20.10.5
 API version:      1.41 (minimum version 1.12)
 Go version:       go1.13.15
 Git commit:       363e9a8
 Built:            Tue Mar  2 20:32:17 2021
 OS/Arch:          linux/amd64
 Experimental:     false
 containerd:
 Version:          1.4.4
 GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
 Version:          1.0.0-rc93
 GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
 Version:          0.19.0
 GitCommit:        de40ad0
错误是:

The Compose file './docker-compose.yml' is invalid because: services.jenkins.volumes contains an invalid type, it should be an array

-
和值之间应该有一个空格,值应该是字符串。看

版本:“3”
服务:
詹金斯:
集装箱名称:詹金斯
图片:詹金斯/詹金斯
端口:
- "8080:8080"
卷数:
-“${PWD}/jenkins_home:/var/jenkins_home”
网络:
-网
网络:
净:

-
和值之间应该有一个空格,值应该是字符串。看

版本:“3”
服务:
詹金斯:
集装箱名称:詹金斯
图片:詹金斯/詹金斯
端口:
- "8080:8080"
卷数:
-“${PWD}/jenkins_home:/var/jenkins_home”
网络:
-网
网络:
净:

您应该在
docker compose
文件中的
-
之后添加一个
空格。我还建议在
docker compose
中使用
relative
路径,而不是使用
PWD
变量,因此
部分中的文件如下所示:

version: '3'
services:
  jenkins:
    container_name: jenkins
    image: jenkins/jenkins
    ports:
      - "8080:8080"
    volumes:
      -$PWD/jenkins_home: /var/jenkins_home
    networks:
      - net
networks:
  net:
volumes:
    - /path/to/jenkins_home:/var/jenkins_home
或:


还要记住,不要在
之前或之后添加空格:

您应该在
docker compose
文件中的
-
之后添加
空格。我还建议在
docker compose
中使用
relative
路径,而不是使用
PWD
变量,因此
部分中的文件如下所示:

version: '3'
services:
  jenkins:
    container_name: jenkins
    image: jenkins/jenkins
    ports:
      - "8080:8080"
    volumes:
      -$PWD/jenkins_home: /var/jenkins_home
    networks:
      - net
networks:
  net:
volumes:
    - /path/to/jenkins_home:/var/jenkins_home
或:


还请记住不要在
之前或之后添加空格:

谢谢,这解决了问题。谢谢,这解决了问题。