问题
I am trying to deploy a web service using Drone and the docker plugin. My image takes about an hour to build, due to a number of large dependencies. To speed up build times, I would like to place a number of my service's dependencies (that are not going to change often) in a base image, and just build my actual code (a python flask app) on top of this base when deploying.
I am hosting the base image in a private repository, with the following line in my Dockerfile:
FROM: my_private_repo.com/my_base_image:latest
but I'm not sure how to correctly give Drone access to this repo.
I currently have the following error in my build job:
Step 1/11 : FROM:xxx
pull access denied for xxx, repository does not exist or may require 'docker login'
time="2018-01-17T13:13:33Z" level=fatal msg="exit status 1"
Is there a way for me to configure the docker plugin to login automatically.
For context, my YAML is something like:
push-feature:
image: plugins/docker
secrets: [docker_username, docker_password]
repo: xxx/yyy/zzz
registry: xxx
tags: "feature"
when:
event: push
branch:
exclude: [ dev, master ]
回答1:
You can try:
Do a
docker login
on the host (if you have multiple agents on multiple server you need to do in all agent host servers)Use the
docker
image this repo needs the trusted flag turned on in order to mount host volumes
pipeline:
build:
image: docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock your-private-registry.com:8080
commands:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker build -t myorg/myimage .
来源:https://stackoverflow.com/questions/48326673/building-privately-hosted-base-image-drone-io