exec /usr/bin/bash: exec format error when 'docker run' an image on aarch64 host after 'docker buildx'

173 views Asked by At

I have a docker image that can be loaded as container on amd64 host, and I want to run its container on an arm64 host, so I have tried

docker buildx build --platform linux/arm64 -t <image-name>-arm -f Dockerfile . --load

with Dockerfile

FROM topsailcbd/<image-name>:latest

WORKDIR /path/to/dir
  • the build was run on amd64 host.

However, when trying to generate a container after loading the image on the arm64 host by

docker run -it --name <name>  -p 8899:8899 -v /path/on/host:/path/on/container <image-name>-arm:latest

This error comes with ALL operations with this container including this docker run:

exec /usr/bin/bash: exec format error

Appendix:

1.

$ docker image inspect <image-name>-arm:latest
[
    {
        "Id": "sha256:dcd4075d4f4036a04bf237b96f71d6a10939049d9c81d433995aecc42ea70486",
        "RepoTags": [
            "<image-name>-arm:latest"
        ],
        "RepoDigests": [],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2023-10-17T16:42:06.951144228Z",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "DISPLAY=:1",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NVIDIA_VISIBLE_DEVICES=all",
                "NVIDIA_DRIVER_CAPABILITIES=graphics,compat32,utility",
                "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu:/usr/local/nvidia/lib:/usr/local/nvidia/lib64",
                "LANG=C.UTF-8",
                "LC_ALL=C.UTF-8",
                "ROS_DISTRO=noetic"
            ],
            "Cmd": [
                "bash"
            ],
            "Image": "",
            "Volumes": null,
            "WorkingDir": "/path/on/host",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "maintainer": "NVIDIA CORPORATION <[email protected]>"
            }
        },
        "Architecture": "arm64",
        "Os": "linux",
        "Size": 17311955987,
        "VirtualSize": 17311955987,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/d9b6141975981c7a3e42eb1f1aeb3cf2a3aab127262076dafe331e24ccec957c/diff:/var/lib/docker/overlay2/074faaa32e1e8f2785a38d732ef0c611165b22b69c04052716bcb07b913905d5/diff:/var/lib/docker/overlay2/c84a3b56ddce36adc774e1f6b58b7984778308aafa12d54c7d60412a6568c250/diff:/var/lib/docker/overlay2/9f60ce238e939930b46245237def8d9f4d087f591354a6cb67c9dabf8b605052/diff:/var/lib/docker/overlay2/96a9afd9393cb3f27292c97891cf83ccebbd3eb682ce50921ae0b17217de409d/diff:/var/lib/docker/overlay2/65a6cf6015647a845283ad783840aa0992f65e8c3439309440e6fbbf09e3418e/diff:/var/lib/docker/overlay2/2a41aa80ff3197248d0da9abd6b3ff964e6e329d352ac1d20273f35e8f6257c1/diff:/var/lib/docker/overlay2/e268e6320c580eb19f39822df0912beb42939a3c0c520fca917df844c6b1e63a/diff:/var/lib/docker/overlay2/23b464b2c7d2545640edf70b45151dcc8d5a1696f4717d82b493f90907a103ef/diff:/var/lib/docker/overlay2/77fd661c8fc50c78295b5f6f184bcabeea0c4be7a1fa363f5b6e3637c0299665/diff:/var/lib/docker/overlay2/f1b6a77de8c07bd9333dd5010e466dee97c68bf4ff8d659e0fc8729431e62905/diff:/var/lib/docker/overlay2/9526c160cdc25664afde0b4582011207884a1f1dec18bc59f8fef265b177f56b/diff:/var/lib/docker/overlay2/e6ac730f2018464f6b322775f6b9608b54272db8b666ca3b7f12b38dfbce77af/diff:/var/lib/docker/overlay2/e68ca8803b3cae814a104beb6f8c94bf0ee6b35681fc89f590a91d11e94f7217/diff:/var/lib/docker/overlay2/438b08743fc53dc4325370b0266e3851c7bbd39263e4ade81949535b88161573/diff:/var/lib/docker/overlay2/b71a07614546085615c1a8a87d091dd9f75b6d267752f499a6cc4e267a316542/diff:/var/lib/docker/overlay2/a78db34f5fc906d4ec51b8ccea6f76e5e8558f9c6e731302f3257a88e0ffe7ee/diff:/var/lib/docker/overlay2/3f81ab34b020a0e26bc4456f5bfc8da0d8a4682cbfb0ab34b23748b58228e0c2/diff",
                "MergedDir": "/var/lib/docker/overlay2/c71ff886a558e692e092873b5d62e65fcfd2b9ef636145c8131fff6a846ecf4f/merged",
                "UpperDir": "/var/lib/docker/overlay2/c71ff886a558e692e092873b5d62e65fcfd2b9ef636145c8131fff6a846ecf4f/diff",
                "WorkDir": "/var/lib/docker/overlay2/c71ff886a558e692e092873b5d62e65fcfd2b9ef636145c8131fff6a846ecf4f/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:4942a1abcbfa1c325b1d7ed93d3cf6020f555be706672308a4a4a6b6d631d2e7",
                "sha256:c9782094635a516fceb8e0e7bd06b995fd0de8d1abe8e356e61e3ea39a48664a",
                "sha256:77a872376c07dcdeecc5828f8b8456c5b68f3bef97b8f5c78bbed93d556091db",
                "sha256:01d47c79d1406538799479376a108348b2ea6e78eee807347184221d5fa9c0b8",
                "sha256:bddf0af90c949ccde9fa53ba594a6595331c5aaa17e05219c81aa8f5a2fc87eb",
                "sha256:92ce07b196cc5d0c593b2faaa83efa0c75c5a6e37a432909b2cfb4d41aad45a1",
                "sha256:a4f9b64f63d6589695a9b87c22f282e9add810adc178ed13c2a18df55dc50a87",
                "sha256:f25f6e6031765425276071327c71327475a699c819185167c136bc4326f381a4",
                "sha256:960b336da428c3af3a9af47e015d2aa9d914b50379ccff56e67b0014cf3f30b3",
                "sha256:039a3f45e7b2fcbd96360c3642c174c8294548f6d256e929619e6b3b8e912d84",
                "sha256:f3d7ce651306186b0a4d331a981244d58a9a459972c504e6d0e6bc215e13e5a9",
                "sha256:f7af19da9881169d7aa3cd64fd79fd026bbf05c12808983a54f1bba743fb02a0",
                "sha256:f6cfaf06822c9a12e4259da7f6d7a3446f33f1db6029fa922cacb5faa1a75cfd",
                "sha256:2ddc4dd0a8176bab8778323af5d651a46dffc4cd95d2026df86707c1575112c8",
                "sha256:f671c81f0c642a911c1f811f0ec41793f9a553335af83f53f40fdf1611447d29",
                "sha256:03b0782724a5448ecee2e066c36383094935e339c9729f33376690a4e45d30a3",
                "sha256:9a3e4f3b5e9000f1ace84efd041a3a8a988f61ee51fb22e34a1e7569ed030e3d",
                "sha256:83eb345ed85f8c2a7ddd5a3f78b5317399a7cea1a217fc37a5a94f808e8834ef",
                "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

$ uname -a 
Linux nx 4.9.201-tegra #1 SMP PREEMPT Fri Jan 15 14:54:23 PST 2021 aarch64 aarch64 aarch64 GNU/Linux
$ docker -v
Docker version 20.10.12 build 20.10.12-0ubuntu2-18.04.1

The host is NVIDIA Jetson Xavier.

3.

I also tried to open /usr/bin/bash of container before docker buildx to examine the shebang, but it seems to be garbled text.

4.

docker logs <container-name> has only one message showing exec format error.

5.

This error still exists even if I add this arg: --entrypoint=/bin/bash Also, there is no such file as /usr/local/bin/docker-entrypoint.sh.

0

There are 0 answers