使用Jenkins在shell脚本中将docker映像推送到docker hub
推送docker映像时出错:使用Jenkins在shell脚本中将docker映像推送到docker hub,docker,jenkins,Docker,Jenkins,推送docker映像时出错: denied: requested access to the resource is denied unauthorized: authentication required script returned exit code 1 Jenkins文件阶段: stage('upload docker') { steps { sh "./upload_docker.sh"
denied: requested access to the resource is denied
unauthorized: authentication required
script returned exit code 1
Jenkins文件阶段:
stage('upload docker') {
steps {
sh "./upload_docker.sh"
}
}
在upload_docker文件中:
docker push username/repo:3
我将用户添加到docker组
我把詹金斯加入了码头工人小组
我将Jenkins添加到用户组,反之亦然
我已将docker配置文件的权限更改为允许所有。您需要先访问docker hub,然后才能将映像推送到其中。要将docker映像推送到专用注册表,您需要:
docker工作流
插件用户名/密码凭证
来自Jenkins的参考我是从ubuntu用户登录的。如果你登录了Jenkins,试试下面的方法,它可以工作!我登录到该实例,并将用户更改为Jenkins用户。然后我又添加了凭证。但这是最好的方法吗?还是我应该遵循下面的方法?
docker.withRegistry('https://registry.example.com', 'credentials-id') {
def customImage = docker.build("my-image:${env.BUILD_ID}")
/* Push the container to the custom Registry */
customImage.push()
}