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

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

Why are my docker-compose failing to build?

问题

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

  1. [+] Building 2.4s (2/3)
  2. [+] Building 2.5s (3/3) FINISHED
  3. => [internal] load build definition from Dockerfile 0.0s
  4. => => transferring dockerfile: 3.39kB 0.0s
  5. => [internal] load .dockerignore 0.0s
  6. => => transferring context: 264B 0.0s
  7. => ERROR [internal] load metadata for docker.io/library/ruby:3.1.0-preview1-buster 2.4s
  8. ------
  9. > [internal] load metadata for docker.io/library/ruby:3.1.0-preview1-buster:
  10. ------
  11. 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:

  1. # 好的参考资料
  2. # https://github.com/dirkdk/docker-rails-demo
  3. # https://www.digitalocean.com/community/tutorials/containerizing-a-ruby-on-rails-application-for-development-with-docker-compose
  4. FROM ruby:3.1.0-preview1-buster
  5. RUN apt-get update && apt-get -y install curl gnupg
  6. 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
  7. ...
  8. # 更多Docker文件的内容...
  9. 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.

  1. # Good References
  2. # https://github.com/dirkdk/docker-rails-demo
  3. # https://www.digitalocean.com/community/tutorials/containerizing-a-ruby-on-rails-application-for-development-with-docker-compose
  4. FROM ruby:3.1.0-preview1-buster
  5. RUN apt-get update && apt-get -y install curl gnupg
  6. 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
  7. RUN curl -q https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
  8. RUN apt-get -y update
  9. RUN apt-get install --fix-missing --no-install-recommends -qq -y \
  10. build-essential \
  11. vim \
  12. wget gnupg \
  13. git-all \
  14. curl \
  15. ssh \
  16. wkhtmltopdf \
  17. postgresql-client-11 libpq5 libpq-dev -y
  18. RUN wget -qO- https://deb.nodesource.com/setup_14.x | bash -
  19. RUN apt-get install -y nodejs
  20. RUN wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
  21. RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
  22. RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
  23. RUN apt-get update
  24. RUN apt-get install yarn
  25. RUN apt-get install less
  26. RUN apt-get install nano
  27. RUN apt-get install libmagickwand-dev
  28. RUN apt-get clean
  29. RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  30. ARG INSTALL_PATH=/firebolt
  31. ENV INSTALL_PATH $INSTALL_PATH
  32. WORKDIR $INSTALL_PATH
  33. # Copy gemfile & package.json, do NOT install unless this is a production build
  34. # For local development these are maintained in cached volumes
  35. COPY Gemfile Gemfile.lock /firebolt/
  36. COPY package.json yarn.lock ./
  37. # Only need to pass in the rails master key if this is a production build
  38. ARG production
  39. COPY scripts/ /firebolt/scripts
  40. RUN scripts/potential_package_install.sh $production
  41. # Copy the entire directory
  42. COPY . /firebolt
  43. # For convenience, lets copy over a .bashrc file
  44. COPY .bashrc /root/.bashrc
  45. # Precompile assets if this is a production build and not in render (otherwise we use webpacker in development)
  46. # Render (our cloud service provider) was having problems with precompiling assets because we would require more than
  47. # 4GB of RAM and that's all they offered. There were a few options
  48. # 1) They could increase their RAM limit (no plans to do so)
  49. # 2) They could offer deployment straight from a private docker image (on the roadmap but currently requires build)
  50. # 3) [Selected] We could commit the assets to our repo then skip the asset compilation step on render. We only do it in
  51. # the github action which then submits another commit
  52. ARG precompile_assets
  53. RUN echo "Production Build: $precompile_assets"
  54. RUN scripts/potential_asset_precompile.sh $precompile_assets
  55. # Designate the entrypoint which will run migrations and start a rails server (this should only run for production)
  56. # Overridden in docker-compose for development
  57. # TODO: We shouldn't need to override this everywhere, we should just not be executing if it isn't production
  58. RUN chmod +x scripts/migrate_and_start.sh
  59. # Change ImageMagick PDF policy.xml
  60. # RUN sed -i_bak 's/rights="none" pattern="PDF"/rights="read | write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml
  61. # Install jpg/pdf extensions
  62. RUN apt-get -y update
  63. RUN apt-get -y install poppler-utils
  64. RUN apt-get -y install img2pdf
  65. 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 镜像:

  1. $ docker pull ruby:3.1.0-preview1-buster

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

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

英文:

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

  1. $ 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:

确定