The docker-compose
file is like this:
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:
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 .
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. I also recommend using relative
path instead of using PWD
variable in docker-compose
, so your file in volumes
part would be like this:
volumes:
- /path/to/jenkins_home:/var/jenkins_home
Or:
volumes:
- jenkins_home:/var/jenkins_home
Also remember do not add space before or after :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.