如何拉马拉松需要被授权的docker形象

我想用marathon部署一个docker容器,如果docker镜像没有授权,镜像可以正常拉,但是当我试图从需要授权的仓库拉出镜像时,任务部署失败,响应是

Failed to launch container: Failed to run 'docker -H unix:///var/run/docker.sock pull example.com/web:laest': exited with status 1; stderr='Error response from daemon: repository example.com/web not found: does not exist or no pull access ' 

我把/var/run/docker.sock文件的权限更改为777节点上的master,但问题仍然出现,似乎权限不是问题的根本原因; 我尝试在节点上运行“docker login”,并手动拉取图像,然后马拉松任务正常运行,我的马拉松json如下所示:

 { "id": "/web", "cmd": "docker login --username='sam' --passwoer='123456' example.com/web:latest", "cpus": 0.3, "mem": 32, "disk": 0, "instances": 1, "env": { "EMAIL_USE_TLS": "False", "DATABASE_URI": "mysql://user:123456@RDS:3306/test" }, "container": { "type": "DOCKER", "volumes": [ { "containerPath": "/data/supervisor/", "hostPath": "/data/workspace/logs/supervisor/", "mode": "RW" } ], "docker": { "image": "daocloud.io/gizwits2015/gwaccounts:1.6.0", "network": "BRIDGE", "portMappings": [ { "containerPort": 0, "hostPort": 0, "servicePort": 10000, "protocol": "tcp", "labels": {} } ], "privileged": false, "parameters": [ { "key": "add-host", "value": "RDS:10.66.125.161" } ], "forcePullImage": false } }, "portDefinitions": [ { "port": 10000, "protocol": "tcp", "name": "default", "labels": {} } ] } 

我怎样才能拉马拉松授权的形象?

您应该阅读: https : //mesosphere.github.io/marathon/docs/native-docker-private-registry.html

按照步骤1,并在步骤2中更换uris部分

 "fetch" : [ { "uri" : "https://path.to/file", "extract" : true, "outputFile" : "dockerConfig.tar.gz" } ] 

我在这里写了更详细的解释: http : //blog.itaysk.com/2017/05/22/using-a-custom-private-docker-registry-with-marathon