logdna / logspout

LogDNA Docker integration
MIT License
16 stars 20 forks source link

arm/multi-arch support #11

Closed dubo-dubon-duponey closed 3 years ago

dubo-dubon-duponey commented 5 years ago

Hey there.

Would be nice to get a proper multi-architecture image for this.

Nowadays, you may use buildx for that, which makes it fairly trivial.

CircleCI probably doesn't support the appropriate docker version for that though.

dubo-dubon-duponey commented 5 years ago

Upstream knows about this... https://github.com/gliderlabs/logspout/issues/340

mwohlert commented 5 years ago

Also would really like to see this arm support.

darinspivey commented 3 years ago

Closing. Multi-arch support has been added in this PR

phistrom commented 2 years ago

Edit: @cederberg addresses all my concerns in this post with his reply below. tl;dr the /bin/logspout binary inside the image is correct and you can ignore the warnings

Original Post No matter what I do, the image I pull is always `linux/amd64`. Take a look at the [logdna/logspout:v1.3.1-arm64 ](https://hub.docker.com/layers/logdna/logspout/v1.3.1-arm64/images/sha256-39955efa29212d88652597773671d59f04169af7761ab2ddf44b676a9a560501) tag, and you will see the platform shows as `linux/amd64` and not `linux/arm64`. If you look at the [logdna/logspout:latest](https://hub.docker.com/layers/logdna/logspout/latest/images/sha256-39955efa29212d88652597773671d59f04169af7761ab2ddf44b676a9a560501) tag and switch the platform to `linux/arm64` using the dropdown, you will notice it has an identical SHA256 to [logdna/logspout:v1.3.1-arm64 ](https://hub.docker.com/layers/logdna/logspout/v1.3.1-arm64/images/sha256-39955efa29212d88652597773671d59f04169af7761ab2ddf44b676a9a560501) If I run ``` docker pull --platform linux/arm64 logdna/logspout:latest ``` and then ``` docker inspect logdna/logspout@sha256:39955efa29212d88652597773671d59f04169af7761ab2ddf44b676a9a560501 | grep Architecture ``` (that is the SHA256 for the `linux/arm64` platform for the `latest` tag on Dockerhub), it returns `"Architecture": "amd64",`. If I run containers from the image, the Docker Desktop GUI on Apple Silicon displays [this warning badge and tooltip](https://i.strmb.org/2112/amd64-warning.png). On Amazon Linux 2 on an EC2 `c6g.large` instance (an ARM64 VM running on AWS), if I run ``` docker run -d --name logdna -e LOGDNA_KEY -v /var/run/docker.sock:/var/run/docker.sock logdna/logspout ``` I receive the following warning, but the container does appear to run ok: ``` WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested ``` So unless I'm missing something, I don't think a `linux/arm64/v8` image actually exists on Dockerhub, and it doesn't appear that I can build it manually from the Dockerfile in this repo.
cederberg commented 2 years ago

Yes, the image for linux/arm64/v8 contains incorrect meta-data that suggests it is linux/amd64. The Docker manifest XML for logdna/logspout:latest is however tagged correctly:

$> docker manifest inspect logdna/logspout:latest
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 738,
         "digest": "sha256:a52e4887fa672cc7b6c76ca24f650cc69d04f1bbd207a95a2dc45f4d5e77a6e2",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 738,
         "digest": "sha256:39955efa29212d88652597773671d59f04169af7761ab2ddf44b676a9a560501",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}

Why is this so, you might ask? Well, it is caused by the Docker build tools setting image metadata to the architecture where the image is built. And it cannot easily be changed afterwards (AFAIK).

But Logspout is written in Go, which can easily be cross-compiled to other architectures by setting GOARCH, GOOS and so on. So, in spite of the warnings, the static binary is actually compiled for the right architecture. You can inspect the binary with a tool like file or similar to verify this.

Once Docker gets their cross-compilation act together, this will probably go away. But currently the only way to get proper metadata into images that I know of is to use the docker buildx tools (BuildKit) which until recently (still?) were marked experimental.