Docker Community Forums

Share and learn in the Docker community.

[solved] Failing to build dockerfile for ARM servers; rpc error: code = Unknown desc = executor failed running [/bin/sh -c apk update]

I wrote a dockerfile, put it on github and added the docker.publish action file.

It’s meant to run a small single server application on a secure Linux environment.
I chose Alpine Linux for that reason.

However, docker hub seems to have issue with this, I think?
I’m new to docker hub.

Dockerfile

# Build SafeNetwork Docker container
FROM arm64v8/alpine:latest
LABEL version="1.0"
LABEL maintainer="Folât Pjêrsômêj"
LABEL release-date="2021-01-31"

# Update and install dependencies
RUN apk update
RUN apk add bash #unix shell to run install script
RUN apk add curl #cUrl to transfer data
RUN apk add jq #Json processor to locate maidsafe's lastest tarball releases urls.
RUN apk add cargo #Install the rust package manager
# Make profile file with exported PATH and refresh the shell (while building)
SHELL ["/bin/bash", "--login", "-c"]
RUN echo 'export PATH=$PATH:/root/.safe/cli' > ~/.profile && source ~/.profile
# Set ENV PATH (after build will be used to find the safe node command)
ENV PATH=$PATH:/root/.safe
# Create safe folders
RUN mkdir -p ~/.safe/{node,cli}
# Install the safe network node
RUN curl -L $(curl --silent https://api.github.com/repos/maidsafe/safe_network/releases/latest \ 
| jq --arg PLATFORM_ARCH "$(echo `uname -m`)" \ 
-r '.assets[] | select(.name | endswith($PLATFORM_ARCH+"-unknown-linux-musl.tar.gz")).browser_download_url') \
| tar xz -C ~/.safe/node
# Install the safe network command line interface
RUN curl -L $(curl --silent https://api.github.com/repos/maidsafe/sn_cli/releases/latest \ 
| jq --arg PLATFORM_ARCH "$(echo `uname -m`)" \ 
-r '.assets[] | select(.name | endswith($PLATFORM_ARCH+"-unknown-linux-musl.tar.gz")).browser_download_url') \
| tar xz -C ~/.safe/
# Add the fleming test network
RUN safe networks add fleming-testnet https://sn-node.s3.eu-west-2.amazonaws.com/config/node_connection_info.config
RUN safe networks switch fleming-testnet
# Join the safe network
RUN safe node join
# Expose PORT of the node 
EXPOSE 12000
# Launch safe on Docker command
CMD ["safe"]

log output on github actions

Run docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
  with:
    context: .
    push: true
    tags: ghcr.io/safenetwork-community/safenetwork-node:main
    labels: org.opencontainers.image.title=safenetwork-node
  org.opencontainers.image.description=Safe network node for hosting data and earning Safe Network Tokens.
  org.opencontainers.image.url=https://github.com/safenetwork-community/safenetwork-node
  org.opencontainers.image.source=https://github.com/safenetwork-community/safenetwork-node
  org.opencontainers.image.version=main
  org.opencontainers.image.created=2021-07-19T23:00:21.327Z
  org.opencontainers.image.revision=d38ab70ad1c7877756681b65cca77101402ac027
  org.opencontainers.image.licenses=GPL-3.0
    load: false
    no-cache: false
    pull: false
    github-token: ***
  env:
    REGISTRY: ghcr.io
    IMAGE_NAME: safenetwork-community/safenetwork-node
Docker info
  /usr/bin/docker version
  Client:
   Version:           20.10.7+azure
   API version:       1.41
   Go version:        go1.13.15
   Git commit:        f0df35096d5f5e6b559b42c7fde6c65a2909f7c5
   Built:             Mon May 31 09:40:07 2021
   OS/Arch:           linux/amd64
   Context:           default
   Experimental:      true
  
  Server:
   Engine:
    Version:          20.10.7+azure
    API version:      1.41 (minimum version 1.12)
    Go version:       go1.13.15
    Git commit:       b0f5bc36fea9dfb9672e1e9b1278ebab797b9ee0
    Built:            Tue Jun  1 22:34:42 2021
    OS/Arch:          linux/amd64
    Experimental:     false
   containerd:
    Version:          1.4.6+azure
    GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
   runc:
    Version:          1.0.0
    GitCommit:        84113eef6fc27af1b01b3181f31bbaf708715301
   docker-init:
    Version:          0.19.0
    GitCommit:        
  /usr/bin/docker info
  Client:
   Context:    default
   Debug Mode: false
   Plugins:
    buildx: Build with BuildKit (Docker Inc., 0.5.1+azure)
  
  Server:
   Containers: 0
    Running: 0
    Paused: 0
    Stopped: 0
   Images: 16
   Server Version: 20.10.7+azure
   Storage Driver: overlay2
    Backing Filesystem: extfs
    Supports d_type: true
    Native Overlay Diff: false
    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: 84113eef6fc27af1b01b3181f31bbaf708715301
   init version: 
   Security Options:
    apparmor
    seccomp
     Profile: default
   Kernel Version: 5.8.0-1036-azure
   Operating System: Ubuntu 20.04.2 LTS
   OSType: linux
   Architecture: x86_64
   CPUs: 2
   Total Memory: 6.791GiB
   Name: fv-az77-843
   ID: 6JGB:KGAD:JIZK:W3I7:6SNN:GUKH:JTOD:KEID:ZBNP:W4YP:EDVO:WSTV
   Docker Root Dir: /var/lib/docker
   Debug Mode: false
   Username: githubactions
   Registry: https://index.docker.io/v1/
   Labels:
   Experimental: false
   Insecure Registries:
    127.0.0.0/8
   Live Restore Enabled: false
  
/usr/bin/docker buildx build --label org.opencontainers.image.title=safenetwork-node --label org.opencontainers.image.description=Safe network node for hosting data and earning Safe Network Tokens. --label org.opencontainers.image.url=https://github.com/safenetwork-community/safenetwork-node --label org.opencontainers.image.source=https://github.com/safenetwork-community/safenetwork-node --label org.opencontainers.image.version=main --label org.opencontainers.image.created=2021-07-19T23:00:21.327Z --label org.opencontainers.image.revision=d38ab70ad1c7877756681b65cca77101402ac027 --label org.opencontainers.image.licenses=GPL-3.0 --tag ghcr.io/safenetwork-community/safenetwork-node:main --iidfile /tmp/docker-build-push-u5PGsI/iidfile --push .
#1 [internal] load build definition from Dockerfile
#1 sha256:fbe83fefa7a0839d23749b5c2483c6c3e5836dd85898e4a8e47f2cd47abb08cd
#1 transferring dockerfile: 1.78kB done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:02b7fcf47ea2ffc5ccd097237dc63952589d851fcc2bd778b2f50d18555431ec
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/arm64v8/alpine:latest
#3 sha256:5163fd92a226ba3b0f132a44635bd5b38271ee4f8b21eb8bca7fae36b70338f8
#3 ...

#4 [auth] arm64v8/alpine:pull token for registry-1.docker.io
#4 sha256:8ec6b790ed26a5677b4c82774472060446f650158bd8675d04bd41835a3adf7d
#4 DONE 0.0s

#3 [internal] load metadata for docker.io/arm64v8/alpine:latest
#3 sha256:5163fd92a226ba3b0f132a44635bd5b38271ee4f8b21eb8bca7fae36b70338f8
#3 DONE 0.7s

#5 [ 1/13] FROM docker.io/arm64v8/alpine:latest@sha256:53b74ddfc6225e3c8cc84d7985d0f34666e4e8b0b6892a9b2ad1f7516bc21b54
#5 sha256:8dbba89caf3a11728e6a9eb0433dbb3972a03fed4fc39672641423d90ebaa054
#5 resolve docker.io/arm64v8/alpine:latest@sha256:53b74ddfc6225e3c8cc84d7985d0f34666e4e8b0b6892a9b2ad1f7516bc21b54 done
#5 sha256:53b74ddfc6225e3c8cc84d7985d0f34666e4e8b0b6892a9b2ad1f7516bc21b54 528B / 528B done
#5 sha256:b0e47758dc53e7391c7abf92fd56fd959bf37fb74574feba3d557b4182d15801 1.47kB / 1.47kB done
#5 sha256:58ab47519297212468320b23b8100fc1b2b96e8d342040806ae509a778a0a07a 0B / 2.71MB 0.1s
#5 sha256:58ab47519297212468320b23b8100fc1b2b96e8d342040806ae509a778a0a07a 2.71MB / 2.71MB 0.2s done
#5 extracting sha256:58ab47519297212468320b23b8100fc1b2b96e8d342040806ae509a778a0a07a
#5 extracting sha256:58ab47519297212468320b23b8100fc1b2b96e8d342040806ae509a778a0a07a 0.1s done
#5 DONE 0.4s

#6 [ 2/13] RUN apk update
#6 sha256:3b71f47369953973e2782eb4c47af014810758ed2ff45d6d1d64a0f421de4128
#6 0.282 standard_init_linux.go:228: exec user process caused: exec format error
#6 ERROR: executor failed running [/bin/sh -c apk update]: exit code: 1
------
 > [ 2/13] RUN apk update:
------
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c apk update]: exit code: 1
Error: buildx call failed with: error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c apk update]: exit code: 1

Docker Hub is the SaaS container image registry provided by Docker, Inc. You are running into a local issue with building your image.

I took your Dockerfile and ran it just fine on Docker Desktop for Mac, so I’m guessing there is a setting for the GitHub action build-push-action that we’re missing.

I would recommend looking over the docs for the build-push-action surrounding mutli-platform builds. You are building with GitHub Actions, which is on linux x86, but you want to build for arm. I’m guessing you will need to specify that explicitly like it does in the documentation. e.g. platforms: linux/amd64,linux/arm64

In addition to this, I noted a few things about your Dockerfile I would recommend improving, if you would like them:

  1. Use the official image like alpine:latest. These are officially scanned and supported by Docker and partners to be the best starting point for various operating systems. Docker images can be multi-platform, so you could still use FROM alpine:latest and build for linux_amd64 and linux_arm64 at the same time. It’s pretty cool and provides flexibility moving forward.
  2. You are running a few commands towards the end of the Dockerfile and I’m guessing you want to run those after the image is already running. I don’t know your exact use-case, but just wanted to point it out that you are joining some cluster as a node, but then shutting the intermediate container down and saving it as a Docker Image (essentially a compressed file with extra metatdata). You will want to instead have a file that runs these commands and put them in something like /docker-entrypoint.sh. Then in your Dockerfile you have ENTRYPOINT ["/docker-entrypoint.sh"]
RUN safe networks add fleming-testnet https://sn-node.s3.eu-west-2.amazonaws.com/config/node_connection_info.config
RUN safe networks switch fleming-testnet
# Join the safe network
RUN safe node join

Hopefully this all helps!

1 Like

That solved the issue!

It’s the standard docker-publish.yml github file which explicity states that they are provided by a third-party and leads straight to docker hub.

I will take a look at that. Thank you again!

1 Like

I don’t know, because I want the container to do two things.

  • Run a node.
  • Let someone use it’s Command Line Interface.

These commands start the node.

RUN safe networks add fleming-testnet https://sn-node.s3.eu-west-2.amazonaws.com/config/node_connection_info.config
RUN safe networks switch fleming-testnet
# Join the safe network
RUN safe node join

This one starts the Command Line Interface, allowing the user to manage the node.

CMD ["safe"]

I’m not trying to be argumentative or anything, just trying to help :grinning_face_with_smiling_eyes:

What I’m trying to say is that nothing is running after you run these commands. A Dockerfile is a set of instructions to build an artifact which can be run elsewhere.

You have this Dockerfile which you build with docker build . -t test (this will export an image called test which you can see by running docker image ls. But then when you run docker ps, there are no running containers. At this point, you would need to run docker run -ti test to actually run a container.

Anyways, after testing a bit further locally, the only command that doesn’t work is the safe node join in your Dockerfile. And by “not work” I mean that it doesn’t seem to have any effect on the end state of your running container.

I created a test case. Feel free to ignore it, or feel free to ask more questions and I can guide you further :grinning_face_with_smiling_eyes:

2 Likes