为什么我的docker-compose构建失败?

huangapple go评论101阅读模式
英文:

Why are my docker-compose failing to build?

问题

我刚刚将我的Docker桌面升级到新版本,但它破坏了我的Docker,其他镜像可以工作,但唯一需要的镜像根本无法构建,我收到以下错误消息:

[+] Building 2.4s (2/3)
[+] Building 2.5s (3/3) FINISHED
 => [internal] load build definition from Dockerfile 0.0s
 => => transferring dockerfile: 3.39kB 0.0s
 => [internal] load .dockerignore 0.0s
 => => transferring context: 264B 0.0s
 => ERROR [internal] load metadata for docker.io/library/ruby:3.1.0-preview1-buster 2.4s
------
 > [internal] load metadata for docker.io/library/ruby:3.1.0-preview1-buster:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``

Docker文件如下,我的机器是一台运行最新版本Docker桌面的Mac M1:

# 好的参考资料
# https://github.com/dirkdk/docker-rails-demo
# https://www.digitalocean.com/community/tutorials/containerizing-a-ruby-on-rails-application-for-development-with-docker-compose

FROM ruby:3.1.0-preview1-buster

RUN apt-get update && apt-get -y install curl gnupg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(grep -oP 'VERSION_CODENAME=\K\w+' /etc/os-release)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
...

# 更多Docker文件的内容...

ENTRYPOINT [ "scripts/migrate_and_start.sh" ]

我已经清除了缓存、镜像,重新安装了Docker,更改了Docker版本和镜像版本,但问题仍然存在。

英文:

I just upgraded my docker desktop to a new version, and it broke my docker, other images work but the only one i need simply does not build and i got this error:

+] Building 2.4s (2/3)
[+] Building 2.5s (3/3) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 3.39kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 264B 0.0s
=> ERROR [internal] load metadata for docker.io/library/ruby:3.1.0-preview1-buster 2.4s

> [internal] load metadata for docker.io/library/ruby:3.1.0-preview1-buster:

failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``

Docker file below
and my machine is a Mac m1 running the latest version of docker-desktop.

# Good References
# https://github.com/dirkdk/docker-rails-demo
# https://www.digitalocean.com/community/tutorials/containerizing-a-ruby-on-rails-application-for-development-with-docker-compose

FROM ruby:3.1.0-preview1-buster

RUN apt-get update && apt-get -y install curl gnupg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(grep -oP 'VERSION_CODENAME=\K\w+' /etc/os-release)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN curl -q https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get -y update
RUN apt-get install --fix-missing --no-install-recommends -qq -y \
        build-essential \
        vim \
        wget gnupg \
        git-all \
        curl \
        ssh \
        wkhtmltopdf \
        postgresql-client-11 libpq5 libpq-dev -y
RUN wget -qO- https://deb.nodesource.com/setup_14.x  | bash -
RUN apt-get install -y nodejs
RUN wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
RUN apt-get update
RUN apt-get install yarn
RUN apt-get install less
RUN apt-get install nano
RUN apt-get install libmagickwand-dev
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ARG INSTALL_PATH=/firebolt
ENV INSTALL_PATH $INSTALL_PATH
WORKDIR $INSTALL_PATH

# Copy gemfile & package.json, do NOT install unless this is a production build
# For local development these are maintained in cached volumes
COPY Gemfile Gemfile.lock /firebolt/
COPY package.json yarn.lock ./

# Only need to pass in the rails master key if this is a production build
ARG production
COPY scripts/ /firebolt/scripts
RUN scripts/potential_package_install.sh $production

# Copy the entire directory
COPY . /firebolt

# For convenience, lets copy over a .bashrc file
COPY .bashrc /root/.bashrc

# Precompile assets if this is a production build and not in render (otherwise we use webpacker in development)
# Render (our cloud service provider) was having problems with precompiling assets because we would require more than
# 4GB of RAM and that's all they offered. There were a few options
# 1) They could increase their RAM limit (no plans to do so)
# 2) They could offer deployment straight from a private docker image (on the roadmap but currently requires build)
# 3) [Selected] We could commit the assets to our repo then skip the asset compilation step on render. We only do it in
#    the github action which then submits another commit
ARG precompile_assets
RUN echo "Production Build: $precompile_assets"
RUN scripts/potential_asset_precompile.sh $precompile_assets

# Designate the entrypoint which will run migrations and start a rails server (this should only run for production)
# Overridden in docker-compose for development
# TODO: We shouldn't need to override this everywhere, we should just not be executing if it isn't production
RUN chmod +x scripts/migrate_and_start.sh

# Change ImageMagick PDF policy.xml
# RUN sed -i_bak 's/rights="none" pattern="PDF"/rights="read | write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml

# Install jpg/pdf extensions
RUN apt-get -y update
RUN apt-get -y install poppler-utils
RUN apt-get -y install img2pdf

ENTRYPOINT [ "scripts/migrate_and_start.sh" ]

I've cleared the cache, cleared the images, reinstalled the docker, changed docker version and the image version.

答案1

得分: 0

你可以单独测试是否能够拉取 Docker 镜像:

$ docker pull ruby:3.1.0-preview1-buster

如果成功下载,那么你应该能够构建你的 Dockerfile。

如果无法工作,镜像标签可能与 M1 机器不兼容。然后尝试从 Docker Hub 中选择另一个标签。

英文:

You can test whether you can pull the docker image separately:

$ docker pull ruby:3.1.0-preview1-buster

If it is downloaded successfully then you should be able to build your Dockerfile.

If it doesn't work the image tag might not be compatible with the M1 machine. Then try another tag from Docker Hub.

huangapple
  • 本文由 发表于 2023年3月4日 08:53:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75633004.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定