example-voting-app icon indicating copy to clipboard operation
example-voting-app copied to clipboard

Result app doesn't run on ARM; Copied Tini binary is x86_64

Open mkturner opened this issue 3 years ago • 1 comments

Please provide the following information so we can assess the issue you're having

Description

The Dockerfile for the result app will not produce a working image on ARM platform. The base image node:10-slim has ARM builds. The final built image will run then exit instantly. There is an error that reveals an x86_64 binary is trying to run.

Steps to reproduce the issue, if relevant:

  1. Use arm64 machine (m1 mac in this case)
  2. Build & run vote, redis, worker, db; link vote to redis, link worker to redis and db
  3. Cast a vote
  4. Build & run example-voting-app/result, link to db

Describe the results you received: The container starts and stop instantly. When you map a local port to port 80 on the container nothing will be there.

/lib64/ld-linux-x86-64.so.2: No such file or directory

Describe the results you expected: result container runs and accepts traffic, reporting votes from db

Additional information you deem important (e.g. issue happens only occasionally): [https://github.com/zabbix/zabbix-docker/issues/777](Similar issue) in another repo, describing fix.

Output of docker version:

Client:
 Cloud integration: 1.0.17
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.16.4
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:23 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:55:36 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-beta.6)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 41
  Running: 37
  Paused: 0
  Stopped: 4
 Images: 23
 Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.25-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 1.942GiB
 Name: docker-desktop
 ID: YAWB:FVN4:N54P:I3YR:WZAC:RTGI:35CF:EEWS:PCHI:TOF2:XLVZ:BQUU
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, Docker for Mac, Docker for Windows, VirtualBox, physical, etc.): Docker Desktop for Mac macOS 11.4 M1/arm64

mkturner avatar Aug 01 '21 16:08 mkturner

I know the fix, This line: ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini

Needs to become this: ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-arm64 /tini

I want to submit a pull request but I'm not sure about the preferred way to solve the issue. Since no logic is supported in Dockerfile, there needs to be two Dockerfiles -- one for x86_64 and one for ARM64. I don't think that's the optimal solution. More likely, include a shell script that pulls the right binary based on architecture and RUN it during build. Something like:

#!/bin/bash
arch=$(arch)
TINI_VERSION=v0.19.0
if [[ $arch == arm* || $arch =~ ^aarch ]]; then
        curl https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-arm64 /tini
elif [[ $arch == x86_64 ]]; then
        curl https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
fi

Maybe there is an even better solution, but those are what I came up with. Thoughts?

mkturner avatar Aug 01 '21 16:08 mkturner

Will be fixed by https://github.com/dockersamples/example-voting-app/pull/268

BretFisher avatar Dec 09 '22 23:12 BretFisher