当我尝试在gitlab管道上运行deploy
作业时,出现以下错误;
$ docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
/bin/bash: line 84: docker: command not found
我的gitlab-ci.yml
看起来像这样
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
stages:
- lint
- test
- build
- build-image
- deploy
deploy:
stage: deploy
image: registry.gitlab.com/username/someimage:latest
script:
- some deploy command
only:
refs:
- master
- develop
- staging
答案 0 :(得分:1)
docker login
中的 before_script
是根据您指定的私有映像在容器中执行的:registry.gitlab.com/username/someimage:latest
该图像未安装docker
,因此出现错误消息。
根据您的情况,您可以:
apt-get update && apt-get install docker.io
这实际上取决于最终要实现的目标。
答案 1 :(得分:0)
image: docker:git
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
stages:
- lint
- test
- build
- build-image
- deploy
deploy:
stage: deploy
image: registry.gitlab.com/username/someimage:latest
script:
- apt update
- ...
only:
refs:
- master
- develop
- staging