Lambda Container Python
Prereqs
- Install Docker Desktop
Create Docker Image
- Create a new file:
Dockerfile- If you don’t install the Lambda Runtime Interface Emulator, then this App will fail when you do
docker runfrom local or ECS. I think Lambda Runtime Interface Client is trying to talk to Lambda and without Lambda or Emulator it’ll fail. - In the
cmdblock, your reference must match the FILENAME.DEFINITION exactly. So in this case, the name of file we’ll create isapp.pyand the definition ishandler.
- If you don’t install the Lambda Runtime Interface Emulator, then this App will fail when you do
- Create a new
appdirectory - Create a new file under this directory,
app.pyIn this python code, we print the payload which will contain the name and the version of python. - Go to the directory where this
Dockerfileis located - Build it using this command
docker build -t myfunction:latest .
- You should see it inside your Docker Desktop
Deploy the container
- Run it, expose port 9000
docker run -d -p 9000:8080 myfunction:latest
Test it (Powershell)
- Run this Change the name of the person to see what happens. You can also change the keyname to see what happens.
- You should see this as your output

- You should see this in your App
