Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.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
使用Jenkins在shell脚本中将docker映像推送到docker hub_Docker_Jenkins - Fatal编程技术网

使用Jenkins在shell脚本中将docker映像推送到docker hub

使用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"

推送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"
            }
        }
在upload_docker文件中:

docker push username/repo:3
我将用户添加到docker组

我把詹金斯加入了码头工人小组

我将Jenkins添加到用户组,反之亦然


我已将docker配置文件的权限更改为允许所有。

您需要先访问docker hub,然后才能将映像推送到其中。

要将docker映像推送到专用注册表,您需要:

  • 安装
    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()
    }