Docker build fails with "ERROR: unknown compilers(c)" when installing numpy

Hello!
I’m fairly new working w/ Docker
I was working on a project and suddenly i started to have some build issues. It is really strange for me as I did not make any changes on the Dockerfile or a .dockerignore file that I have. The commands were working until recently and I need help figuring out how to troubleshoot this problem

Here is the command that I’m trying to run

docker build --platform=linux/amd64 .

I’m building it on that platform as i’m pushing the image into a AWS ECR repo.

Log

[internal] load build definition from Dockerfile
	transferring 351/0 0.003
[internal] load metadata for docker.io/library/python:alpine3.19
[internal] load .dockerignore
[internal] load build context
	transferring 619851/0 0.032
[1/6] FROM docker.io/library/python:alpine3.19@sha256:bd07a7ea723ee0fa0059e7b995d0ee7d97d6ad96b92a7a94cae3b882da389a36
	resolve docker.io/library/python:alpine3.19@sha256:bd07a7ea723ee0fa0059e7b995d0ee7d97d6ad96b92a7a94cae3b882da389a36 0/0 0.008
	done 9019/9019 -0.735
	done 1736/1736 -0.577
	done 4733/4733 -0.036
	done 3359103/3359103 0.798
	done 249/249 1.021
	done 630348/630348 1.192
	done 12085580/12085580 2.498
	extract 0/0 0.06
	extract 0/0 0.135
	extract 0/0 0.342
	extract 0/0 0
[2/6] WORKDIR /flagged_items_app
[3/6] COPY requirements.txt .
[4/6] RUN apk add --no-cache gcc=13.2.1_git20231014-r0 musl-dev=1.2.4_git20230717-r4 libffi-dev=3.4.4-r3
	fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
	fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
	(1/16) Installing libgcc (13.2.1_git20231014-r0)
	(2/16) Installing jansson (2.14-r4)
	(3/16) Installing libstdc++ (13.2.1_git20231014-r0)
	(4/16) Installing zstd-libs (1.5.5-r8)
	(5/16) Installing binutils (2.41-r0)
	(6/16) Installing libgomp (13.2.1_git20231014-r0)
	(7/16) Installing libatomic (13.2.1_git20231014-r0)
	(8/16) Installing gmp (6.3.0-r0)
	(9/16) Installing isl26 (0.26-r1)
	(10/16) Installing mpfr4 (4.2.1-r0)
	(11/16) Installing mpc1 (1.3.1-r1)
	(12/16) Installing gcc (13.2.1_git20231014-r0)
	(13/16) Installing linux-headers (6.5-r0)
	(14/16) Installing pkgconf (2.1.0-r0)
	(15/16) Installing libffi-dev (3.4.4-r3)
	(16/16) Installing musl-dev (1.2.4_git20230717-r4)
	Executing busybox-1.36.1-r19.trigger
	OK: 164 MiB in 45 packages
[5/6] RUN pip3 install --no-cache-dir -r requirements.txt
	Ignoring backports.zoneinfo: markers 'python_version < "3.9"' don't match your environment
	Collecting APScheduler==3.9.1 (from -r requirements.txt (line 1))
	Downloading APScheduler-3.9.1-py2.py3-none-any.whl.metadata (6.2 kB)
	Collecting attrs==21.4.0 (from -r requirements.txt (line 2))
	Downloading attrs-21.4.0-py2.py3-none-any.whl.metadata (9.8 kB)
	Collecting boto3==1.34.76 (from -r requirements.txt (line 4))
	Downloading boto3-1.34.76-py3-none-any.whl.metadata (6.6 kB)
	Collecting botocore==1.34.76 (from -r requirements.txt (line 5))
	Downloading botocore-1.34.76-py3-none-any.whl.metadata (5.7 kB)
	Collecting certifi==2024.2.2 (from -r requirements.txt (line 6))
	Downloading certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
	Collecting cffi==1.16.0 (from -r requirements.txt (line 7))
	Downloading cffi-1.16.0.tar.gz (512 kB)
	Installing build dependencies: started
	Installing build dependencies: finished with status 'done'
	Getting requirements to build wheel: started
	Getting requirements to build wheel: finished with status 'done'
	Preparing metadata (pyproject.toml): started
	Preparing metadata (pyproject.toml): finished with status 'done'
	Collecting charset-normalizer==2.0.12 (from -r requirements.txt (line 8))
	Downloading charset_normalizer-2.0.12-py3-none-any.whl.metadata (11 kB)
	Collecting click==8.1.3 (from -r requirements.txt (line 9))
	Downloading click-8.1.3-py3-none-any.whl.metadata (3.2 kB)
	Collecting cryptography==42.0.5 (from -r requirements.txt (line 10))
	Downloading cryptography-42.0.5-cp39-abi3-musllinux_1_2_aarch64.whl.metadata (5.3 kB)
	Collecting defusedxml==0.7.1 (from -r requirements.txt (line 11))
	Downloading defusedxml-0.7.1-py2.py3-none-any.whl.metadata (32 kB)
	Collecting et-xmlfile==1.1.0 (from -r requirements.txt (line 12))
	Downloading et_xmlfile-1.1.0-py3-none-any.whl.metadata (1.8 kB)
	Collecting Flask==2.3.2 (from -r requirements.txt (line 13))
	Downloading Flask-2.3.2-py3-none-any.whl.metadata (3.7 kB)
	Collecting idna==3.7 (from -r requirements.txt (line 14))
	Downloading idna-3.7-py3-none-any.whl.metadata (9.9 kB)
	Collecting importlib-metadata==4.11.4 (from -r requirements.txt (line 15))
	Downloading importlib_metadata-4.11.4-py3-none-any.whl.metadata (4.0 kB)
	Collecting iniconfig==1.1.1 (from -r requirements.txt (line 16))
	Downloading iniconfig-1.1.1-py2.py3-none-any.whl.metadata (2.4 kB)
	Collecting itsdangerous==2.1.2 (from -r requirements.txt (line 17))
	Downloading itsdangerous-2.1.2-py3-none-any.whl.metadata (2.9 kB)
	Collecting Jinja2==3.1.2 (from -r requirements.txt (line 18))
	Downloading Jinja2-3.1.2-py3-none-any.whl.metadata (3.5 kB)
	Collecting jira==3.2.0 (from -r requirements.txt (line 19))
	Downloading jira-3.2.0-py3-none-any.whl.metadata (10.0 kB)
	Collecting jmespath==1.0.1 (from -r requirements.txt (line 20))
	Downloading jmespath-1.0.1-py3-none-any.whl.metadata (7.6 kB)
	Collecting loguru==0.7.2 (from -r requirements.txt (line 21))
	Downloading loguru-0.7.2-py3-none-any.whl.metadata (23 kB)
	Collecting MarkupSafe==2.1.1 (from -r requirements.txt (line 22))
	Downloading MarkupSafe-2.1.1.tar.gz (18 kB)
	Installing build dependencies: started
	Installing build dependencies: finished with status 'done'
	Getting requirements to build wheel: started
	Getting requirements to build wheel: finished with status 'done'
	Preparing metadata (pyproject.toml): started
	Preparing metadata (pyproject.toml): finished with status 'done'
	Collecting numpy==1.26.4 (from -r requirements.txt (line 23))
	Downloading numpy-1.26.4.tar.gz (15.8 MB)
	━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.8/15.8 MB 4.0 MB/s eta 0:00:00
	Installing build dependencies: started
	Installing build dependencies: finished with status 'done'
	Getting requirements to build wheel: started
	Getting requirements to build wheel: finished with status 'done'
	Installing backend dependencies: started
	Installing backend dependencies: finished with status 'done'
	Preparing metadata (pyproject.toml): started
	Preparing metadata (pyproject.toml): finished with status 'error'
	error: subprocess-exited-with-error
	
	× Preparing metadata (pyproject.toml) did not run successfully.
	│ exit code: 1
	╰─> [22 lines of output]
	+ /usr/local/bin/python3.13 /tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114/vendored-meson/meson/meson.py setup /tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114 /tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114/.mesonpy-blchqrqi -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114/.mesonpy-blchqrqi/meson-python-native-file.ini
	The Meson build system
	Version: 1.2.99
	Source dir: /tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114
	Build dir: /tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114/.mesonpy-blchqrqi
	Build type: native build
	Project name: NumPy
	Project version: 1.26.4
	C compiler for the host machine: cc (gcc 13.2.1 "cc (Alpine 13.2.1_git20231014) 13.2.1 20231014")
	C linker for the host machine: cc ld.bfd 2.41
	
	../meson.build:1:0: ERROR: Unknown compiler(s): [['c++'], ['g++'], ['clang++'], ['nvc++'], ['pgc++'], ['icpc'], ['icpx']]
	The following exception(s) were encountered:
	Running `c++ --version` gave "[Errno 2] No such file or directory: 'c++'"
	Running `g++ --version` gave "[Errno 2] No such file or directory: 'g++'"
	Running `clang++ --version` gave "[Errno 2] No such file or directory: 'clang++'"
	Running `nvc++ --version` gave "[Errno 2] No such file or directory: 'nvc++'"
	Running `pgc++ --version` gave "[Errno 2] No such file or directory: 'pgc++'"
	Running `icpc --version` gave "[Errno 2] No such file or directory: 'icpc'"
	Running `icpx --version` gave "[Errno 2] No such file or directory: 'icpx'"
	
	A full log can be found at /tmp/pip-install-oza8_hmf/numpy_b46a2c62637f427685ce6b9d75ea1114/.mesonpy-blchqrqi/meson-logs/meson-log.txt
	[end of output]
	
	note: This error originates from a subprocess, and is likely not a problem with pip.
	error: metadata-generation-failed
	
	× Encountered error while generating package metadata.
	╰─> See above for output.
	
	note: This is an issue with the package mentioned above, not pip.
	hint: See above for details.

Dockerfile:

FROM python:alpine3.19

WORKDIR /flagged_items_app

COPY requirements.txt .

RUN apk add --no-cache gcc=13.2.1_git20231014-r0 musl-dev=1.2.4_git20230717-r4 libffi-dev=3.4.4-r3

RUN pip3 install --no-cache-dir -r requirements.txt


ENV PYTHONUNBUFFERED=TRUE

COPY . .

EXPOSE 8080

CMD ["python3", "./server.py"]

requirements txt.

APScheduler==3.9.1
attrs==21.4.0
backports.zoneinfo==0.2.1;python_version<"3.9"
boto3==1.34.76
botocore==1.34.76
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==2.0.12
click==8.1.3
cryptography==42.0.5
defusedxml==0.7.1
et-xmlfile==1.1.0
Flask==2.3.2
idna==3.7
importlib-metadata==4.11.4
iniconfig==1.1.1
itsdangerous==2.1.2
Jinja2==3.1.2
jira==3.2.0
jmespath==1.0.1
loguru==0.7.2
MarkupSafe==2.1.1
numpy==1.26.4
oauthlib==3.2.0
openpyxl==3.0.10
packaging==21.3
pandas==2.2.2
pbr==5.9.0
pluggy==1.0.0
prometheus-client==0.14.1
py==1.11.0
pycparser==2.21
PyJWT==2.4.0
pyparsing==3.0.9
pytest==7.1.2
pytest-mock==3.7.0
python-dateutil==2.8.2
python-dotenv==0.20.0
pytz==2022.1
pytz-deprecation-shim==0.1.0.post0
requests==2.28.1
requests-oauthlib==1.3.1
requests-toolbelt==0.9.1
s3transfer==0.10.0
six==1.16.0
tomli==2.0.1
tzdata==2022.7
tzlocal==4.2
urllib3==1.26.18
uuid==1.30
Werkzeug==3.0.1
zipp==3.8.0
pyyaml==6.0.1

From what I saw it seems like there is a conflict on some package versions but As I mentioned above, it’s really weird as it was working a few days ago. I’m working on a Mac

Additional Info

  • Docker version 27.3.1, build ce1223035a
  • Docker Desktop 4.34.3 (170107)

Thanks a lot!

The tag you are using in the FROM instruction does not specify the Python version. The image with the tag “alpine3.19” changed 5 days ago to include Python 3.13. You probably need to try with an older python image.

Thank you @rimelek ! I used another image tag taking into account what you said and that worked like a charm! Thanks a lot!