[英]Gitlab Fargate unable to pull image during CI/CD
config.toml配置文件
concurrent = 100
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "xyz_project_name"
url = "https://gitlab.com/"
token = "yieSD7McA-WFMtFv5nzg"
executor = "custom"
builds_dir = "/opt/gitlab-runner/builds"
cache_dir = "/opt/gitlab-runner/cache"
[runners.custom]
privileged = true
config_exec = "/opt/gitlab-runner/fargate"
config_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "config"]
prepare_exec = "/opt/gitlab-runner/fargate"
prepare_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "prepare"]
run_exec = "/opt/gitlab-runner/fargate"
run_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "run"]
cleanup_exec = "/opt/gitlab-runner/fargate"
cleanup_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "cleanup"]
.gitlab-ci.yaml .gitlab-ci.yaml
image: docker:latest
stages:
- install_dependencies
- lint
- bundle
- build
- deploy
install_dependencies:
stage: install_dependencies
image: node:14
script:
- node -v
- npm -v
- ls node_modules
- npm install --unsafe-perm
artifacts:
paths:
- node_modules/
- version.v
- repo.name
lint:
image: node:14
stage: lint
script:
- npm run lint
bundle:
image: node:14
stage: bundle
script:
- npm run build:prod
artifacts:
paths:
- dist/
build:
stage: build
image: aws-docker:2.0.0
services:
- docker:dind
before_script:
- aws ecr get-login-password | docker login --username AWS --password-stdin $AWS_ECR_REGISTRY
script:
- docker build -t $DOCKER_REGISTRY $DOCKER_REGISTRY:latest .
- docker push $DOCKER_REGISTRY:latest
pipeling giving following error管道给出以下错误
$ node -v
bash: line 140: node: command not found
ERRO[2022-04-20T03:49:47Z] Application execution failed
This pipeline works fine with a normal GitLab runner But when I moved it to Fargate runner, It's giving this error.这条管道与普通的 GitLab 跑步者一起工作正常但是当我将它移到 Fargate 跑步者时,它给出了这个错误。 I think Fargate runner is not able to pull the image
我认为 Fargate runner 无法拉取图像
What I can do, I can install node v-14 in the container image.我能做什么,我可以在容器映像中安装节点 v-14。 But what about
aws-docker:2.0.0
但是
aws-docker:2.0.0
呢
Thanks for taking the time to be thorough in your request, it really helps!感谢您抽出宝贵的时间来详细说明您的要求,这真的很有帮助!
The fargate custom executor ignores the image:
directive entirely, as mentioned in the documentation : fargate 自定义执行程序完全忽略
image:
指令,如文档中所述:
The
image
andservice
keywords in yourgitlab-ci.yml
file are ignored.gitlab-ci.yml
文件中的image
和service
关键字将被忽略。 The runner only uses the values specified in the task definition.跑步者仅使用任务定义中指定的值。
As described in the documentation, when setting up your fargate runner, you must prepare an image that contains all the software you will need.如文档中所述,在设置 Fargate Runner 时,您必须准备一个包含您需要的所有软件的图像。 This must be done in advance.
这必须提前完成。 The job uses this image that is defined in your ECS task definition created in step 6 of the setup documentation.
该作业使用在设置文档的第 6 步中创建的 ECS 任务定义中定义的此图像。
But what about aws-docker:2.0.0
但是 aws-docker:2.0.0 呢
Another key limitation of Fargate is that it is not possible to use docker
inside of Fargate because using docker
inside of a container requires the container to be privileged , but privileged containers are forbidden by AWS on Fargate, thus this is not possible. Fargate 的另一个关键限制是无法在 Fargate 内部使用
docker
,因为在容器内部使用docker
需要容器具有特权,但 AWS 在 Fargate 上禁止特权容器,因此这是不可能的。
Also note, even if this limitation didn't exist, you'll also have the same issue with services:
as with image:
-- the service is ignored by the executor.另请注意,即使不存在此限制,您也会遇到与
services:
与image:
-- 执行程序会忽略该服务。
There are some alternative ways to build and push images that don't require a docker daemon (and therefore don't require privileged containers) such as using kaniko to build images.有一些替代方法可以构建和推送不需要 docker 守护进程(因此不需要特权容器)的图像,例如使用 kaniko构建图像。 You can also see the GitLab blog for guidance on how to build containers on Fargate with AWS CodeBuild
您还可以查看 GitLab 博客,了解有关如何使用 AWS CodeBuild 在 Fargate 上构建容器的指南
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.