I try to build an ansible image for amd64 and arm64 using docker buildx
but my build always fails, it's like the builder can't support another arch than the one running on the current hardware I am running debian and I installed qemu-user-static
and binfmt-support
so docker buildx
ls gives the following result
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
hopeful_wilson * docker-container
hopeful_wilson0 unix:///var/run/docker.sock running linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
inspiring_lamarr docker-container
inspiring_lamarr0 unix:///var/run/docker.sock running linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
default docker
default default running linux/amd64, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/arm/v7, linux/arm/v6
and my dockerfile
FROM python:alpine3.15
ADD . /tmp
WORKDIR /tmp
RUN adduser -D -s /bin/sh -h /home/ansible ansible ansible
RUN apk update && apk add openssh-client bash
RUN rm -rf /var/cache/apk/*
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r requirements.txt
# RUN python3 -m pip install ansible
RUN sed -i "s@/bin/sh@/bin/bash@g" /etc/passwd
WORKDIR /
USER ansible
to build I run
docker buildx build --platform linux/amd64,linux/arm64 -t ansible-multi-arch .
And here the result of my build
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 121.4s (24/25)
=> [internal] booting buildkit 5.8s
=> => pulling image moby/buildkit:buildx-stable-1 1.9s
=> => creating container buildx_buildkit_competent_bohr0 3.9s
=> [internal] load build definition from Dockerfile 0.8s
=> => transferring dockerfile: 419B 0.0s
=> [internal] load .dockerignore 0.9s
=> => transferring context: 2B 0.0s
=> [linux/amd64 internal] load metadata for docker.io/library/python:alpine3.15 3.0s
=> [linux/arm64 internal] load metadata for docker.io/library/python:alpine3.15 3.2s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> [linux/arm64 1/10] FROM docker.io/library/python:alpine3.15@sha256:74d722200c8cd876dcbd5cfb1d093c916e85d4318f051c2f3cfe5067c27cfbd5 12.9s
=> => resolve docker.io/library/python:alpine3.15@sha256:74d722200c8cd876dcbd5cfb1d093c916e85d4318f051c2f3cfe5067c27cfbd5 0.3s
=> => sha256:7025a0ca8e87cb11983c19a8a09007c64a9ebe5d2f9efe96b36658d2221721b7 231B / 231B 0.5s
=> => sha256:a1b0595ea6d26aa03a510d790d1fde94888af6ca5914982b6c9b6fd03c7a620c 3.04MB / 3.04MB 1.5s
=> => sha256:938e9f93fe23985a1f4d1d090e4ced82c31b2fabd4922b7761e42cfe7b56b9d7 12.67MB / 12.67MB 3.3s
=> => sha256:5e18021c0d0bf0a6f79a44bbbd33f12adeb2ef1358b140d8e7ef36e20c1e63b3 682.39kB / 682.39kB 0.7s
=> => sha256:47517142f6ba87eca6b7bdca1e0df160b74671c81e4b9605dad38c1862a43be3 2.72MB / 2.72MB 1.2s
=> => extracting sha256:47517142f6ba87eca6b7bdca1e0df160b74671c81e4b9605dad38c1862a43be3 0.3s
=> => extracting sha256:5e18021c0d0bf0a6f79a44bbbd33f12adeb2ef1358b140d8e7ef36e20c1e63b3 0.5s
=> => extracting sha256:938e9f93fe23985a1f4d1d090e4ced82c31b2fabd4922b7761e42cfe7b56b9d7 1.6s
=> => extracting sha256:7025a0ca8e87cb11983c19a8a09007c64a9ebe5d2f9efe96b36658d2221721b7 1.7s
=> => extracting sha256:a1b0595ea6d26aa03a510d790d1fde94888af6ca5914982b6c9b6fd03c7a620c 1.6s
=> [internal] load build context 1.4s
=> => transferring context: 49.12kB 0.0s
=> [linux/amd64 1/10] FROM docker.io/library/python:alpine3.15@sha256:74d722200c8cd876dcbd5cfb1d093c916e85d4318f051c2f3cfe5067c27cfbd5 9.0s
=> => resolve docker.io/library/python:alpine3.15@sha256:74d722200c8cd876dcbd5cfb1d093c916e85d4318f051c2f3cfe5067c27cfbd5 0.3s
=> => sha256:4211f440f0679002fb62db619c32ebb8894e25c77a19249fdf742fd4dbfb6555 3.04MB / 3.04MB 0.7s
=> => sha256:e8792c1c2edc87ab51a97c35dd511344734a625d1e67e3fd27dcfaa37ebe8eaf 231B / 231B 0.3s
=> => sha256:abed0206f3914209d0e7a549b92f3b0c85b421285ab998e63ea64d093f71289f 681.67kB / 681.67kB 1.3s
=> => sha256:9621f1afde84053b2f9b6ff34fc7f7460712247c01cbab483c5fa7132cf782ca 2.82MB / 2.82MB 1.1s
=> => sha256:0b0ae0fe5b972748ea6475feec4cd2238797fd89b8870a9f4a572f29488e5f88 12.58MB / 12.58MB 2.8s
=> => extracting sha256:9621f1afde84053b2f9b6ff34fc7f7460712247c01cbab483c5fa7132cf782ca 0.4s
=> => extracting sha256:abed0206f3914209d0e7a549b92f3b0c85b421285ab998e63ea64d093f71289f 0.7s
=> => extracting sha256:0b0ae0fe5b972748ea6475feec4cd2238797fd89b8870a9f4a572f29488e5f88 0.5s
=> => extracting sha256:e8792c1c2edc87ab51a97c35dd511344734a625d1e67e3fd27dcfaa37ebe8eaf 0.3s
=> => extracting sha256:4211f440f0679002fb62db619c32ebb8894e25c77a19249fdf742fd4dbfb6555 1.6s
=> [linux/amd64 2/10] ADD . /tmp 7.0s
=> [linux/arm64 2/10] ADD . /tmp 3.5s
=> [linux/arm64 3/10] WORKDIR /tmp 1.9s
=> [linux/amd64 3/10] WORKDIR /tmp 1.9s
=> [linux/arm64 4/10] RUN adduser -D -s /bin/sh -h /home/ansible ansible ansible 1.6s
=> [linux/amd64 4/10] RUN adduser -D -s /bin/sh -h /home/ansible ansible ansible 1.6s
=> [linux/arm64 5/10] RUN apk update && apk add openssh-client bash 4.3s
=> [linux/amd64 5/10] RUN apk update && apk add openssh-client bash 2.6s
=> [linux/amd64 6/10] RUN rm -rf /var/cache/apk/* 0.5s
=> [linux/amd64 7/10] RUN python3 -m pip install --upgrade pip 5.9s
=> [linux/arm64 6/10] RUN rm -rf /var/cache/apk/* 1.2s
=> [linux/arm64 7/10] RUN python3 -m pip install --upgrade pip 23.5s
=> [linux/amd64 8/10] RUN python3 -m pip install -r requirements.txt 43.1s
=> ERROR [linux/arm64 8/10] RUN python3 -m pip install -r requirements.txt 61.9s
=> [linux/amd64 9/10] RUN sed -i "s@/bin/sh@/bin/bash@g" /etc/passwd 1.4s
------
> [linux/arm64 8/10] RUN python3 -m pip install -r requirements.txt:
#0 3.679 Collecting ansible==6.3.0
#0 3.820 Downloading ansible-6.3.0-py3-none-any.whl (41.0 MB)
#0 8.925 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.0/41.0 MB 5.1 MB/s eta 0:00:00
#0 10.81 Collecting ansible-core==2.13.3
#0 10.84 Downloading ansible_core-2.13.3-py3-none-any.whl (2.1 MB)
#0 11.12 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 7.8 MB/s eta 0:00:00
#0 12.29 Collecting cffi==1.15.1
#0 12.32 Downloading cffi-1.15.1.tar.gz (508 kB)
#0 12.77 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.5/508.5 kB 1.2 MB/s eta 0:00:00
#0 13.15 Preparing metadata (setup.py): started
#0 17.85 Preparing metadata (setup.py): finished with status 'done'
#0 18.91 Collecting cryptography==37.0.4
#0 18.95 Downloading cryptography-37.0.4-cp36-abi3-musllinux_1_1_aarch64.whl (4.1 MB)
#0 19.47 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 8.2 MB/s eta 0:00:00
#0 20.18 Collecting Jinja2==3.1.2
#0 20.22 Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
#0 20.68 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 291.5 kB/s eta 0:00:00
#0 21.19 Collecting MarkupSafe==2.1.1
#0 21.22 Downloading MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_aarch64.whl (30 kB)
#0 22.11 Collecting packaging==21.3
#0 22.15 Downloading packaging-21.3-py3-none-any.whl (40 kB)
#0 22.48 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 kB 96.3 kB/s eta 0:00:00
#0 23.14 Collecting pycparser==2.21
#0 23.17 Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
#0 23.25 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 2.6 MB/s eta 0:00:00
#0 23.55 Collecting pyparsing==3.0.9
#0 23.58 Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
#0 23.66 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 2.1 MB/s eta 0:00:00
#0 23.94 Collecting PyYAML==6.0
#0 23.97 Downloading PyYAML-6.0.tar.gz (124 kB)
#0 24.25 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.0/125.0 kB 479.8 kB/s eta 0:00:00
#0 25.03 Installing build dependencies: started
#0 39.09 Installing build dependencies: finished with status 'done'
#0 39.09 Getting requirements to build wheel: started
#0 46.71 Getting requirements to build wheel: finished with status 'done'
#0 46.73 Preparing metadata (pyproject.toml): started
#0 48.48 Preparing metadata (pyproject.toml): finished with status 'done'
#0 48.66 Collecting resolvelib==0.8.1
#0 48.70 Downloading resolvelib-0.8.1-py2.py3-none-any.whl (16 kB)
#0 49.30 Building wheels for collected packages: cffi, PyYAML
#0 49.30 Building wheel for cffi (setup.py): started
#0 50.82 Building wheel for cffi (setup.py): finished with status 'error'
#0 50.86 error: subprocess-exited-with-error
#0 50.86
#0 50.86 × python setup.py bdist_wheel did not run successfully.
#0 50.86 │ exit code: 1
#0 50.86 ╰─> [47 lines of output]
#0 50.86
#0 50.86 No working compiler found, or bogus compiler options passed to
#0 50.86 the compiler from Python's standard "distutils" module. See
#0 50.86 the error messages above. Likely, the problem is not related
#0 50.86 to CFFI but generic to the setup.py of any Python package that
#0 50.86 tries to compile C code. (Hints: on OS/X 10.8, for errors about
#0 50.86 -mno-fused-madd see http://stackoverflow.com/questions/22313407/
#0 50.86 Otherwise, see https://wiki.python.org/moin/CompLangPython or
#0 50.86 the IRC channel #python on irc.libera.chat.)
#0 50.86
#0 50.86 Trying to continue anyway. If you are trying to install CFFI from
#0 50.86 a build done in a different context, you can ignore this warning.
#0 50.86
#0 50.86 /usr/local/lib/python3.10/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
#0 50.86 warnings.warn(msg, warning_class)
#0 50.86 running bdist_wheel
#0 50.86 running build
#0 50.86 running build_py
#0 50.86 creating build
#0 50.86 creating build/lib.linux-aarch64-cpython-310
#0 50.86 creating build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/error.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/pkgconfig.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/commontypes.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/lock.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/vengine_gen.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/api.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/verifier.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/model.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/cparser.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/__init__.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/recompiler.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/ffiplatform.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/_cffi_include.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/parse_c_type.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/_embedding.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 50.86 running build_ext
#0 50.86 building '_cffi_backend' extension
#0 50.86 creating build/temp.linux-aarch64-cpython-310
#0 50.86 creating build/temp.linux-aarch64-cpython-310/c
#0 50.86 gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DFFI_BUILDING=1 -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.10 -c c/_cffi_backend.c -o build/temp.linux-aarch64-cpython-310/c/_cffi_backend.o
#0 50.86 error: command 'gcc' failed: No such file or directory
#0 50.86 [end of output]
#0 50.86
#0 50.86 note: This error originates from a subprocess, and is likely not a problem with pip.
#0 50.87 ERROR: Failed building wheel for cffi
#0 50.87 Running setup.py clean for cffi
#0 52.15 Building wheel for PyYAML (pyproject.toml): started
#0 54.17 Building wheel for PyYAML (pyproject.toml): finished with status 'done'
#0 54.17 Created wheel for PyYAML: filename=PyYAML-6.0-cp310-cp310-linux_aarch64.whl size=45335 sha256=6180755536e9685dbf4baacd3bfdc04e71f7c56e2467f12a2f994e33065dd5bb
#0 54.18 Stored in directory: /root/.cache/pip/wheels/1d/f3/b4/4aea0992adbed14b36ce9c3857d3707c762a4374479230685d
#0 54.19 Successfully built PyYAML
#0 54.19 Failed to build cffi
#0 55.52 Installing collected packages: resolvelib, PyYAML, pyparsing, pycparser, MarkupSafe, packaging, Jinja2, cffi, cryptography, ansible-core, ansible
#0 58.06 Running setup.py install for cffi: started
#0 59.47 Running setup.py install for cffi: finished with status 'error'
#0 59.50 error: subprocess-exited-with-error
#0 59.50
#0 59.50 × Running setup.py install for cffi did not run successfully.
#0 59.50 │ exit code: 1
#0 59.50 ╰─> [49 lines of output]
#0 59.50
#0 59.50 No working compiler found, or bogus compiler options passed to
#0 59.50 the compiler from Python's standard "distutils" module. See
#0 59.50 the error messages above. Likely, the problem is not related
#0 59.50 to CFFI but generic to the setup.py of any Python package that
#0 59.50 tries to compile C code. (Hints: on OS/X 10.8, for errors about
#0 59.50 -mno-fused-madd see http://stackoverflow.com/questions/22313407/
#0 59.50 Otherwise, see https://wiki.python.org/moin/CompLangPython or
#0 59.50 the IRC channel #python on irc.libera.chat.)
#0 59.50
#0 59.50 Trying to continue anyway. If you are trying to install CFFI from
#0 59.50 a build done in a different context, you can ignore this warning.
#0 59.50
#0 59.50 /usr/local/lib/python3.10/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
#0 59.50 warnings.warn(msg, warning_class)
#0 59.50 running install
#0 59.50 /usr/local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
#0 59.50 warnings.warn(
#0 59.50 running build
#0 59.50 running build_py
#0 59.50 creating build
#0 59.50 creating build/lib.linux-aarch64-cpython-310
#0 59.50 creating build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/error.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/pkgconfig.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/commontypes.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/lock.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/vengine_gen.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/api.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/verifier.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/model.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/cparser.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/__init__.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/recompiler.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/ffiplatform.py -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/_cffi_include.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/parse_c_type.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/_embedding.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-cpython-310/cffi
#0 59.50 running build_ext
#0 59.50 building '_cffi_backend' extension
#0 59.50 creating build/temp.linux-aarch64-cpython-310
#0 59.50 creating build/temp.linux-aarch64-cpython-310/c
#0 59.50 gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DFFI_BUILDING=1 -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.10 -c c/_cffi_backend.c -o build/temp.linux-aarch64-cpython-310/c/_cffi_backend.o
#0 59.50 error: command 'gcc' failed: No such file or directory
#0 59.50 [end of output]
#0 59.50
#0 59.50 note: This error originates from a subprocess, and is likely not a problem with pip.
#0 59.51 error: legacy-install-failure
#0 59.51
#0 59.51 × Encountered error while trying to install package.
#0 59.51 ╰─> cffi
#0 59.51
#0 59.51 note: This is an issue with the package mentioned above, not pip.
#0 59.51 hint: See above for output from the failure.
------
Dockerfile:10
--------------------
8 | RUN rm -rf /var/cache/apk/*
9 | RUN python3 -m pip install --upgrade pip
10 | >>> RUN python3 -m pip install -r requirements.txt
11 | # RUN python3 -m pip install ansible
12 | RUN sed -i "s@/bin/sh@/bin/bash@g" /etc/passwd
--------------------
error: failed to solve: process "/bin/sh -c python3 -m pip install -r requirements.txt" did not complete successfully: exit code: 1
Any Idea ? Thank you