Gopherstack implements the AWS Lambda Runtime API for Docker image-based functions.
Important: Only
PackageType: Imageis supported. Zip-based and S3-based deployments are not implemented.
When you invoke a Lambda function, Gopherstack:
- Pulls the Docker image (if not already cached locally).
- Starts a container from the image, passing environment variables including
AWS_LAMBDA_RUNTIME_API. - The container's runtime bootstrapper calls
GET /runtime/invocation/nexton the Runtime API. - Gopherstack sends the invocation payload.
- The runtime handler calls
POST /runtime/invocation/<id>/responsewith the result. - The container is returned to the warm pool for reuse.
Each function has a pool of pre-warmed containers (size configurable via --lambda-pool-size, default 3). After a successful invocation the container is kept alive and reused for the next invocation. Containers that idle longer than --lambda-idle-timeout (default 10m) are stopped and removed.
The Runtime API is served at http://<LAMBDA_DOCKER_HOST>:<PORT>/_lambda_runtime/:
| Method | Path | Description |
|---|---|---|
GET |
/runtime/invocation/next |
Long-poll for the next invocation |
POST |
/runtime/invocation/{id}/response |
Report a successful result |
POST |
/runtime/invocation/{id}/error |
Report a runtime error |
POST |
/runtime/init/error |
Report an initialisation error |
LAMBDA_DOCKER_HOST must be the IP or hostname the container can use to reach Gopherstack. On Linux with the default Docker bridge this is 172.17.0.1.
| Flag | Env Var | Default | Description |
|---|---|---|---|
--lambda-docker-host |
LAMBDA_DOCKER_HOST |
172.17.0.1 |
Host Lambda containers use to reach Gopherstack |
--lambda-pool-size |
LAMBDA_POOL_SIZE |
3 |
Warm container pool size per function |
--lambda-idle-timeout |
LAMBDA_IDLE_TIMEOUT |
10m |
Idle container lifetime |
--container-runtime |
CONTAINER_RUNTIME |
docker |
docker, podman, or auto |
--container-host |
CONTAINER_HOST |
`` | Override the Docker/Podman socket path |
The caller waits for the function to complete. The response body is returned directly.
aws --endpoint-url http://localhost:8000 lambda invoke \
--function-name my-function \
--payload '{"key":"value"}' \
response.json
cat response.jsonThe invocation returns immediately with HTTP 202. The function runs in the background.
aws --endpoint-url http://localhost:8000 lambda invoke \
--function-name my-function \
--invocation-type Event \
--payload '{"key":"value"}' \
/dev/nullCreate an ESM to trigger a function when messages arrive in an SQS queue:
aws --endpoint-url http://localhost:8000 lambda create-event-source-mapping \
--function-name my-function \
--event-source-arn arn:aws:sqs:us-east-1:000000000000:my-queue \
--batch-size 10 \
--enabledGopherstack polls the SQS queue and delivers message batches to the function automatically.
Create a URL that can invoke the function directly via HTTP:
aws --endpoint-url http://localhost:8000 lambda create-function-url-config \
--function-name my-function \
--auth-type NONEThe returned URL points to the Gopherstack endpoint.
Gopherstack supports Podman as a Docker-compatible runtime.
# Enable the Podman socket
systemctl --user enable --now podman.socket
# Point Gopherstack at Podman
export CONTAINER_RUNTIME=podman
# Optional: set socket path explicitly
export CONTAINER_HOST=unix://${XDG_RUNTIME_DIR}/podman/podman.sock
# Rootless networking — use host's routable IP
export LAMBDA_DOCKER_HOST=host.containers.internal
gopherstackContainer can't reach Gopherstack:
Set LAMBDA_DOCKER_HOST to the IP of the Docker bridge interface (ip addr show docker0 on Linux).
Image pull fails:
Ensure docker pull <image> works from your shell before using Gopherstack.
Function times out:
Increase the function timeout with --timeout in UpdateFunctionConfiguration. Default is 3 seconds.
Cold starts are slow:
Increase --lambda-pool-size to keep more warm containers per function.