docker gitlab 中的奇怪错误 docker: /bin/sh: eval: line 120: docker-compose: 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
当我创建一个新项目时,我总是 copy/paste 来自其他项目的这个脚本 - 它总是工作正常。我总是从一个简单的管道开始(例如,test_app,这个管道 builds/deploys 是一个简单的 flask hello world 脚本)。我有另一个项目具有完全相同的 .gitlab-ci.yml
文件,它成功构建和部署,由以下输出指示:
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 运行ner 上启用 docker-compose
出了点问题。但是,我不明白 - docker-compose.yml 和成功和失败项目的 Dockerfile 几乎相同。我也在两个项目中使用相同的 运行ner。 运行 ls -l
告诉我 docker-compose.yaml 实际上在 docker gitlab 运行ner 的工作目录中。我认为问题一定与这个问题有关 ,但是尝试提出的解决方案(在我的 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:
我发现在另一个项目中使用了相同的 运行ner,并且它能够 运行 docker-compose。所以它必须以某种方式安装。 运行 用户使用的基本图像是 alpine:latest
。
问题已解决:在我的存储库中,文件被命名为 docker-compose.yaml
而不是 docker-compose.yml
两者都是有效的文件格式,所以我的编辑没有抱怨。
论坛,
我遇到了与以下 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
当我创建一个新项目时,我总是 copy/paste 来自其他项目的这个脚本 - 它总是工作正常。我总是从一个简单的管道开始(例如,test_app,这个管道 builds/deploys 是一个简单的 flask hello world 脚本)。我有另一个项目具有完全相同的 .gitlab-ci.yml
文件,它成功构建和部署,由以下输出指示:
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 运行ner 上启用 docker-compose
出了点问题。但是,我不明白 - docker-compose.yml 和成功和失败项目的 Dockerfile 几乎相同。我也在两个项目中使用相同的 运行ner。 运行 ls -l
告诉我 docker-compose.yaml 实际上在 docker gitlab 运行ner 的工作目录中。我认为问题一定与这个问题有关
$ 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:
我发现在另一个项目中使用了相同的 运行ner,并且它能够 运行 docker-compose。所以它必须以某种方式安装。 运行 用户使用的基本图像是 alpine:latest
。
问题已解决:在我的存储库中,文件被命名为 docker-compose.yaml
而不是 docker-compose.yml
两者都是有效的文件格式,所以我的编辑没有抱怨。