Prereqs

  • Install Docker Desktop

Create Docker Image

  1. Create a new file: Dockerfile
    • If you don’t install the Lambda Runtime Interface Emulator, then this App will fail when you do docker run from 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 cmd block, your reference must match the FILENAME.DEFINITION exactly. So in this case, the name of file we’ll create is app.py and the definition is handler.
  2. Create a new app directory
  3. Create a new file under this directory, app.py In this python code, we print the payload which will contain the name and the version of python.
  4. Go to the directory where this Dockerfile is located
  5. Build it using this command
    docker build -t myfunction:latest .
    

    Docker Build

  6. You should see it inside your Docker Desktop New Image

    Deploy the container

  7. Run it, expose port 9000
    docker run -d -p 9000:8080 myfunction:latest
    

Test it (Powershell)

  1. Run this Change the name of the person to see what happens. You can also change the keyname to see what happens.
  2. You should see this as your output Powershell Output
  3. You should see this in your App Docker App Output

References