gpt4 book ai didi

docker - Alpine :WAITINGdocker启动后再继续

转载 作者:行者123 更新时间:2023-12-02 18:14:31 27 4
gpt4 key购买 nike

我在CI / CD机器上使用Alpine linux。下面的docker文件:

FROM node:10.15-alpine
RUN npm i -g sequelize sequelize-cli mysql2
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update
RUN apk add --update git bash openssh terraform aws-cli docker openrc
WORKDIR /var/app

问题是CI尝试执行docker代码时,例如。 docker login,它失败:
[Container] 2019/01/10 11:18:10 Running command $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[Container] 2019/01/10 11:18:10 Command did not exit successfully $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) exit status 1

当我尝试添加行
RUN service docker start

我已经开始使用docker

那我如何等待docker启动呢?

最佳答案

请考虑@DavidMaze的答案,据说DinD不是正确的方法,但是我认为这似乎更容易...此外,我在AWS上找到了有关如何实现此功能的文档。

https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html

我了解到的要点是我需要在CodeBuild上启用特权模式,然后在我的buildspec中,我需要执行以下操作:

phases:
install:
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2&
- timeout -t 15 sh -c "until docker info; do echo .; sleep 1; done"

关于docker - Alpine :WAITINGdocker启动后再继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54127604/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com