unable to execute 'gcc': No such file or directory when running docker build

Viewed 3966

I was trying to create a docker image for my python script and upload it to AWS ECR and then use it in Lambda. Our python runtime is 3.8 shown on the AWS console so I just followed this manual: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base

But I got the error when I run docker build -t image-name .

#6 14.02 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/var/lang/include/python3.8 -c bitarray/_bitarray.c -o build/temp.linux-x86_64-3.8/bitarray/_bitarray.o
#6 14.02 unable to execute 'gcc': No such file or directory
#6 14.02 error: command 'gcc' failed with exit status 1

I double checked and I have gcc installed on my macOS:

Warning: gcc 11.2.0 is already installed and up-to-date.
To reinstall 11.2.0, run:
brew reinstall gcc

Would appreciate some help on resolving this. thanks!

EDIT: This issue originates from me unable to import a CPython library cytoolz when running my script on Lambda, so I consulted these issues to simulate the runtime using docker. https://github.com/Miserlou/Zappa/issues/1717#issuecomment-445821158 https://github.com/ethereum/web3.py/issues/1456#issuecomment-866862759

If there is a better way to import cytoolz without using docker I would also def appreciate some hints!

Thx!!

1 Answers

Add the below commands to get requried things installed.

RUN yum update -y

RUN yum groupinstall 'Development Tools' -y

Sample Dockerfile:

FROM public.ecr.aws/lambda/python:3.9

RUN yum update -y

RUN yum groupinstall 'Development Tools' -y

RUN pip --version
Related