Reputation: 159
I am creating a lambda function based on a docker image following these aws tutorial. I found the image here, specifically public.ecr.aws/lambda/python:3.11
The problem is that in the page is says that the max size of that will be 238 MB, buuut when I build this Dockerfile
FROM public.ecr.aws/lambda/python:3.11
COPY lambda_function.py ${LAMBDA_TASK_ROOT}
CMD [ "lambda_function.handler" ]
with this
docker build -t positions-backend .
and next I run
docker images
I realize that my image is 749MB size
This is my empty lambda function
def handler(event, context):
return {
'statusCode': 200,
'body': {
"msg": "hi :D"
}
}
Why my image is 748MB with an empty project? thanks
Upvotes: 1
Views: 698
Reputation: 425803
I'm not sure where this figure comes from, but if we pull the base image and examine its history, we'll see:
$ docker pull public.ecr.aws/lambda/python:3.11
$ docker history public.ecr.aws/lambda/python:3.11
IMAGE CREATED CREATED BY SIZE COMMENT
e34e3e59cb88 29 hours ago ENTRYPOINT [ "/lambda-entrypoint.sh" ] 0B
<missing> 29 hours ago ENV LAMBDA_RUNTIME_DIR=/var/runtime 0B
<missing> 29 hours ago ENV LAMBDA_TASK_ROOT=/var/task 0B
<missing> 29 hours ago ENV LD_LIBRARY_PATH=/var/lang/lib:/lib64:/us… 0B
<missing> 29 hours ago ENV PATH=/var/lang/bin:/usr/local/bin:/usr/b… 0B
<missing> 29 hours ago ENV TZ=:/etc/localtime 0B
<missing> 29 hours ago ENV LANG=en_US.UTF-8 0B
<missing> 29 hours ago WORKDIR /var/task 0B
<missing> 29 hours ago ADD file:384d41d4058f1d590f048a0c1474041c02f… 56.7kB
<missing> 29 hours ago ADD file:0448654eed630f2f1179287a6e0466928e0… 439MB
<missing> 29 hours ago ADD file:79a77e7c1be9a2c4f77ead609e8d8b71623… 5.85MB
<missing> 29 hours ago ADD file:a1bbc10d9f9f6ba22cee5801afc978c0506… 397B
<missing> 29 hours ago ADD file:178bb853f0ea4e9e47c962179740d55a67f… 627kB
<missing> 29 hours ago ADD file:c39f5f02ed92d44591fa99789f20fd3aa47… 303MB
<missing> 29 hours ago ARCHITECTURE amd64 0B
, which more or less lines up with your observations.
Its largest two layers are 439MB and 303MB in size.
Upvotes: 1