我想创建一个 docker 映像,将其作为容器启动(以配置数据库凭据等),提交这些更改,标记它并将其推送到容器注册表:
from .gitlab-ci.yml:
configure_db_image:
stage: docker_build
tags:
- docker-in-docker
script:
- docker login <gitlab-CI-CR> -u gitlab-ci-token -p $CI_JOB_TOKEN
- docker pull <gitlab-CI-CR>/db-template/db-template-image:latest
- docker tag <gitlab-CI-CR>/db-template/db-template-image:latest <gitlab-CI-CR>/my-project/my-repo/test-db-image:latest
# Remove the container if it exists already
- docker rm -f test-db-image-container || true
- docker create -i -p 5432:5432 --name test-db-image-container --env 'CREATE_ONLY_ON_FIRST_RUN=yes' --env 'DB_USER=user' --env 'DB_PASS=pass' --env 'DB_NAME=dbname' <gitlab-CI-CR>/my-project/my-repo/test-db-image:latest
- docker start -i test-db-image-container
- docker stop test-db-image-container
- docker commit test-db-image-container test-db-image
- docker tag test-db-image <gitlab-CI-CR>/my-project/my-repo/test-db-image:latest
- docker push <gitlab-CI-CR>/my-project/my-repo/test-db-image:latest
我不明白为什么,但尽管docker push
我从注册表中提取的图像没有配置。我哪里错了?