how to build a docker image with private reigistry image ? #12580
-
deal.sh
run pipeline result:
I don't known how to auth the docker private registry. ;( here is the pipeline file:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Please use https://github.com/gocd/gocd/discussions or https://groups.google.com/g/go-cd for general usage questions rather than creating "issues". This is really a general Docker configuration question rather than specific to GoCD. You could change your agent to be pre-logged in to your registry before it runs any jobs, or alternatively if you want to keep it dynamic for each pipeline: Change your #!/usr/bin/env bash
TAG=test-`date +%y%m%d`
REGISTRY=10.0.33.251:5001
IMG=${REGISTRY}/nacos:${TAG}
echo "${DOCKER_REGISTRY_PASSWORD}" | docker login ${REGISTRY} --username "${DOCKER_REGISTRY_USERNAME}" --password-stdin
docker build -f dockerfile.df -t ${IMG} .
docker logout ${REGISTRY} Then configure your pipeline/stage/job to have these environment variables {
"environment_variables": [
{
"name": "DOCKER_REGISTRY_USERNAME",
"encrypted_value": "BLAH"
},
{
"name": "DOCKER_REGISTRY_PASSWORD",
"encrypted_value": "BLAH"
}
]
} To encrypt the values, you can either
|
Beta Was this translation helpful? Give feedback.
-
Thank you so much. It worked successfully. |
Beta Was this translation helpful? Give feedback.
Please use https://github.com/gocd/gocd/discussions or https://groups.google.com/g/go-cd for general usage questions rather than creating "issues".
This is really a general Docker configuration question rather than specific to GoCD. You could change your agent to be pre-logged in to your registry before it runs any jobs, or alternatively if you want to keep it dynamic for each pipeline:
Change your
deal.sh
to something like this