简体   繁体   English

Docker 集线器映像失败,但构建其 Dockerfile 有效。 怎么了?

[英]Docker hub image fails but building its Dockerfile works. What is happening?

I have used Docker-compose a lot recently, but this time I found a container I really want to use but the docker hub's image is not compatible with my arm/v6 raspberry pi.我最近经常使用 Docker-compose,但是这次我找到了一个我很想使用的容器,但是 docker 集线器的图像与我的 arm/v6 raspberry pi 不兼容。 Using it anyway results in无论如何使用它会导致

standard_init_linux.go:219: exec user process caused: exec format error

Strangely, copying the Dockerfile and building it with奇怪的是,复制 Dockerfile 并用

    build:
      context: ./ttrss-docker/src/app

results in the app working well.结果应用程序运行良好。 But for some reason, I can't use the dockerhub's image.但是由于某种原因,我不能使用 dockerhub 的镜像。

In case it matters, the Dockerfile is this , and the Docker Hub image is this .万一这很重要,Dockerfile 就是这个,Docker Hub 图像就是这个

FROM alpine:3.12
EXPOSE 9000/tcp

RUN apk add --no-cache dcron php7 php7-fpm \
    php7-pdo php7-gd php7-pgsql php7-pdo_pgsql php7-mbstring \
    php7-intl php7-xml php7-curl php7-session \
    php7-dom php7-fileinfo php7-json \
    php7-pcntl php7-posix php7-zip php7-openssl \
    git postgresql-client sudo

ADD startup.sh /
ADD updater.sh /
ADD index.php /
ADD dcron.sh /
ADD backup.sh /etc/periodic/weekly/backup

RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf
RUN sed -i.bak 's/\(memory_limit =\) 128M/\1 256M/' /etc/php7/php.ini

RUN mkdir -p /var/www

CMD /startup.sh

Question: if I don't use the Docker hubs image, can Watchtower update my container?问:如果我不使用 Docker 集线器映像,Watchtower 可以更新我的容器吗? If not, does anyone know what's happening and how I can achieve a container that updates via Watchtower?如果没有,有谁知道发生了什么以及如何实现通过 Watchtower 更新的容器?

Many thanks:)非常感谢:)

The image you are pulling has only been built for a single architecture: amd64.您要提取的映像仅针对单一架构构建:amd64。 The resulting binaries and libraries are not usable on other platforms like ARM used by the Raspberry Pi.生成的二进制文件和库不能在其他平台上使用,例如 Raspberry Pi 使用的 ARM。 Below are the debugging steps to verify this.以下是验证这一点的调试步骤。

The manifest is application/vnd.docker.distribution.manifest.v2+json :清单是application/vnd.docker.distribution.manifest.v2+json

$ regctl image manifest --list cthulhoo/ttrss-fpm-pgsql-static
{                                                                                        
  "schemaVersion": 2,
  "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
  "config": {
    "mediaType": "application/vnd.docker.container.image.v1+json",
    "size": 4257,                                                      
    "digest": "sha256:916ae5126809992b922c5db0f41e62a40be245703685e19f51797db95f312e81"
  },
  ...

Checking the architecture of that image:检查该图像的架构:

$ regctl image inspect cthulhoo/ttrss-fpm-pgsql-static --format '{{.Architecture}}'                                    
amd64 

This would need to be fixed by the image creator to build an image for ARM platforms, which you see with the Alpine base image.这需要由映像创建者修复,以便为 ARM 平台构建映像,您可以在 Alpine 基础映像中看到该映像。

$ regctl image manifest --list alpine:3.12        
{                                                          
  "schemaVersion": 2,    
  "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
  "manifests": [
    {                                             
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 528,       
      "digest": "sha256:074d3636ebda6dd446d0d00304c4454f468237fdacf08fb0eeac90bdbfa1bac7",
      "platform": {
        "architecture": "amd64",                 
        "os": "linux"                                                                                                                                                                                                                                                           
      }           
    },
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 528,
      "digest": "sha256:096ebf69d65b5dcb3756fcfb053e6031a3935542f20cd7a8b7c59e1b3cb71558",
      "platform": {
        "architecture": "arm",
        "os": "linux",
        "variant": "v6"
      }
    },
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 528,
      "digest": "sha256:299294be8699c1b323c137f972fd0aa5eaa4b95489c213091dcf46ef39b6c810",
      "platform": {
        "architecture": "arm",
        "os": "linux",
        "variant": "v7"
      }
    },
    ...

Building multi-platform images is often done with buildx .构建多平台映像通常使用buildx完成。 The regctl command used above is part of my regclient project.上面使用的regctl命令是我的regclient项目的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM