[英]gitlab ci error /bin/sh: eval: line 138: docker: not found
[英]Strange error docker in docker gitlab: /bin/sh: eval: line 120: docker-compose: not found
论坛,
我遇到了一个与以下 CICD 脚本相关的奇怪问题:
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
CONTAINER_RELEASE_IMAGE_APP: $CI_REGISTRY_IMAGE/app:latest
CONTAINER_RELEASE_IMAGE_APP_DEV: $CI_REGISTRY_IMAGE/app_dev:latest
# from https://storage.googleapis.com/kubernetes-release/release/stable.txt
K8S_STABLE_VERSION_URL: https://storage.googleapis.com/kubernetes-release/release/v1.18.4/bin/linux/amd64/kubectl
.k8s:
services:
- name: docker:18.09.7-dind
command: ["--mtu=1410"]
variables:
DOCKER_HOST: tcp://localhost:2375
tags:
- kube-onpremise
##################
# ---- DEV ----- #
##################
build_dev:
stage: build
script:
# Login
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
#Try to pull image from container registry
- docker pull $CONTAINER_RELEASE_IMAGE_APP_DEV || true
#Build --pull Dockerfile (build --pull will pull latest version of any base image(s) - in this case python - instead of reusing whatever
#you already have tagged locally). tag it with $CONTAINER_RELEASE_IMAGE_APP_DEV.
#--cache-from is flag for other layers (app code and dependency). In this case we use the $CONTAINER_RELEASE_IMAGE_APP_DEV as cache.
- docker build -f Dockerfile --pull -t $CONTAINER_RELEASE_IMAGE_APP_DEV .
#--cache-from $CONTAINER_RELEASE_IMAGE_APP_DEV
#Push image back into container registry
- docker push $CONTAINER_RELEASE_IMAGE_APP_DEV
only:
changes:
- public/**/*
- Dockerfile
- requirements.txt
- .gitlab-ci.yml
refs:
- dev
deploy_dev:
stage: deploy
script:
#Login, this time with deploy credentials
- docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
# - apk add --no-cache python py2-pip
# - pip install --no-cache-dir docker-compose
- ls -l
#Deploy application to docker swarm, --with-registry-auth indicates that registry authentication details (CI_DEPLOY...) Are send to swarm agents.
- docker stack deploy --compose-file=docker-compose.yml test_app --with-registry-auth
only:
- dev
当我创建一个新项目时,我总是从其他项目中复制/粘贴这个脚本 - 它总是工作正常。 我总是从一个简单的管道开始(例如,这个管道构建/部署的 test_app 是一个简单的 flask hello world 脚本)。 我有另一个项目具有完全相同的.gitlab-ci.yml
文件,它成功构建和部署,由以下 output 指示:
Login Succeeded
$ docker stack deploy --compose-file=docker-compose.yml clever_api --with-registry-auth
Updating service clever_api_uitschieterdetectie_api (id: pdcb2cwpg2xe6wfez0vk7sgap)
Job succeeded
但是,当我尝试在当前项目上运行 CICD 脚本时,我不断得到:
Login Succeeded
$ docker stack deploy --compose-file=docker-compose.yml test_app --with-registry-auth
open docker-compose.yml: no such file or directory
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
我感觉在 gitlab 运行器上启用docker-compose
时出了点问题。 但是,我不明白 - 成功和失败项目的 docker-compose.yml 和 Dockerfile 几乎相同。 我也在为这两个项目使用相同的跑步者。 运行ls -l
显示 docker-compose.yaml 实际上在 docker ZD0493DFC9D7551742B 的工作目录中我认为问题一定与这个问题有关Using docker-compose in a GitLab CI 管道,但尝试提出的解决方案(在我的 gitlab 脚本中注释掉,以供参考)给了我另一个错误:
$ apk add --no-cache python py2-pip
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
py2-pip (missing):
required by: world[py2-pip]
python (missing):
required by: world[python]
Cleaning up file based variables
00:02
ERROR: Job failed: exit code 2
更新 1:我发现在另一个项目中使用了相同的运行器,并且它能够运行 docker-compose。 所以它必须以某种方式安装。 跑步者使用的基本图像是alpine:latest
。
问题已解决:在我的存储库中,文件名为docker-compose.yaml
而不是docker-compose.yml
两者都是有效的文件格式,所以我的编辑没有抱怨。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.