简体   繁体   English

错误:Compose 文件“./docker-compose.yml”无效,因为:services.jenkins.volumes 包含无效类型,它应该是一个数组

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

The docker-compose file is like this: 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:

The docker version information: 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 error is:错误是:

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

There should be a space between - and the value, and the value should be a string. -和值之间应该有一个空格,并且值应该是一个字符串。 See the docker compose volumes documentation .请参阅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:

You should add a space after - in docker-compose file.您应该在docker-compose文件中的-之后添加一个space I also recommend using relative path instead of using PWD variable in docker-compose , so your file in volumes part would be like this:我还建议在docker-compose中使用relative路径而不是使用PWD变量,因此您在volumes部分的文件将如下所示:

volumes:
    - /path/to/jenkins_home:/var/jenkins_home

Or:或者:

volumes:
    - jenkins_home:/var/jenkins_home

Also remember do not add space before or after :还要记住不要在之前或之后添加空格:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:撰写文件“./docker-compose.yml”无效,因为:services.jenkins.networks 包含无效类型 - ERROR: The Compose file './docker-compose.yml' is invalid because: services.jenkins.networks contains an invalid type Compose 文件 '.\docker-compose.yml' 无效,因为:services.web.build 包含无效类型,它应该是字符串,或者 object - The Compose file '.\docker-compose.yml' is invalid because: services.web.build contains an invalid type, it should be a string, or an object 错误:撰写文件“./docker-compose.yml”无效,因为:services.mysql.ports 无效 - ERROR: The Compose file './docker-compose.yml' is invalid because: services.mysql.ports is invalid 错误:撰写文件“./docker-compose.yml”无效,因为:服务不支持的配置选项:“sqlite3” - ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services: 'sqlite3' 错误:撰写文件“.\docker-compose.yml”无效,因为:服务的配置选项不受支持。drupal:“postgres” - ERROR: The Compose file '.\docker-compose.yml' is invalid because: Unsupported config option for services.drupal: 'postgres' 获取错误为 ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services: 'db' while compose - Getting the error as ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services: 'db' while composing 错误:撰写文件 docker-compose.yml 无效 - ERROR: The Compose file docker-compose.yml is invalid docker-compose.yml无效:app.build包含无效类型,它应该是一个字符串 - docker-compose.yml invalid: app.build contains an invalid type, it should be a string Compose 文件“./docker-compose.yml”无效,因为:services.docker-image 的配置选项不受支持:“update_config” - The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services.docker-image: 'update_config' Compose 文件 './docker-compose.yml' 无效,因为:不支持的配置选项 - The Compose file './docker-compose.yml' is invalid because: Unsupported config option
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM