在我的服务器中,我只有一个单行脚本
docker-compose pull && docker-compose up -d
。
当我在服务器中运行此文件时,它会成功按指定的方式提取docker文件并将其放入。
但是,当我尝试在Jenkinsfile中执行此操作时,
stage('Deployment') {
steps {
withCredentials([sshUserPrivateKey(
credentialsId: '<id>',
keyFileVariable: 'KEY_FILE')]) {
sh '''
<authentication steps...>
ssh root@<servername> \
&& cd <proj_root_dir> \
sh ./deploy.sh
ssh-agent -k
'''
}
}
}
它给我一个错误,说,
Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version ("2.0", "2.1", "3.0", "3.1", "3.2") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
我正在使用的版本是3.7
,当我将版本更改为3.2
时,它说它不支持我正在使用的volume
。这很奇怪,因为当我在服务器中手动运行脚本时,它可以正常工作。
有什么想法吗?