我有几个具有类似要求的php应用程序,dockerized gitlab runner和一个docker图像供我的应用程序使用。
自动启动评论应用的最佳解决方案是什么?
我开始使用已连接的docker.sock并添加了我的项目/ home / devenv /在gitlab runner config.toml附加的跑步者:
[runners.docker]
tls_verify = false
image = "docker:latest"
privileged = true
disable_cache = false
volumes = ["/cache", "/home/devenv:/home/devenv"]
测试和构建工作正常,使用图片:.gitlab-ci.yml中的myrepo.com/group/image
然后我的部署失败并出错。 部署部分:
deploy to review:
image: docker:latest
services:
- docker:dind
stage: deploy
script:
- rm -rf /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME
- mkdir /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME
- cp -r ./* /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME/
- docker stop $CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME
- docker rm $CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME
- docker run -d --env ENDLESS_RUN="1" --env VIRTUAL_HOST="$CI_BUILD_REF_NAME.$CI_PROJECT_NAME.$CI_PROJECT_NAMESPACE.e.mydomain.com" --name "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME" -v /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME/httpdocs:/home/web/httpdocs -v /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME/logs:/var/logs myrepo.com/group/image
- docker exec $CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME cd /home/httpdocs/ && npm install && bower install && gulp build
environment:
name: review/$CI_BUILD_REF_NAME
url: http://$CI_BUILD_REF_NAME.$CI_PROJECT_NAME.$CI_PROJECT_NAMESPACE.e.mydomain.com
only:
- branches
except:
- master
运行命令出错:
$ docker run -d --env ENDLESS_RUN="1" --env VIRTUAL_HOST="$CI_BUILD_REF_NAME.$CI_PROJECT_NAME.$CI_PROJECT_NAMESPACE.e.mydomain.com" --name "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME" -v /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME/httpdocs:/home/bitrix/www -v /home/devenv/$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_BUILD_REF_NAME/logs:/var/logs myrepo.com/group/image
Unable to find image 'myrepo.com/group/image:latest' locally
latest: Pulling from group/image
90577c79babf: Pulling fs layer
a74e2caa985d: Pulling fs layer
8729c6ccfcfb: Pulling fs layer
f160b3e340fb: Pulling fs layer
9c19c344e2fa: Pulling fs layer
74a07af12073: Pulling fs layer
...
...
Status: Downloaded newer image for myrepo.com/group/image:latest
docker: An error occurred trying to connect: Post http://docker:2375/v1.24/containers/create?name=olimpia-iam-master: EOF.
See 'docker run --help'.
ERROR: Build failed: exit code 125
答案 0 :(得分:1)
DIND不允许将容积从一个容器安装到另一个容器中。对于您尝试做的事情,您必须share the host docker service with the container