LocalStack Lambda goes Failed: 'Error while creating lambda: Docker not available', Invoke 409 ResourceConflictException; on rootless podman mount the podman socket + set LAMBDA_DOCKER_NETWORK
LocalStack runs each Lambda in its own container, so the LocalStack container needs a Docker API socket. With Docker: -v /var/run/docker.sock:/var/run/docker.sock. With rootless podman: systemctl --user start podman.socket, put LocalStack on a user network and tell it to attach Lambda containers there:
podman network create ls-net
podman run -d --name localstack --network ls-net -p 4566:4566 -e LAMBDA_DOCKER_NETWORK=ls-net -v /run/user/$(id -u)/podman/podman.sock:/var/run/docker.sock:Z localstack/localstack:3.8
What each stage looks like (LocalStack 3.8.1, python3.12 function created with boto3):
- No socket: CreateFunction returns 201, the function goes Pending -> Failed with StateReason Error while creating lambda: Docker not available (InternalError), and Invoke gives ResourceConflictException ... The function is currently in the following state: Failed. The logs say it plainly: Docker not available in the LocalStack container but required to run Lambda functions. Please add the Docker volume mount "/var/run/docker.sock:/var/run/docker.sock". Likely also why a Terraform/CDK deploy seems to hang: it waits for the function to become Active.
- Podman socket but default network: the function becomes Active (LocalStack pulls public.ecr.aws/lambda/python:3.12), but every invoke returns 500 ServiceException after Execution environment ... timed out during startup: the Lambda container can't call back to LocalStack.
- Socket + shared network + LAMBDA_DOCKER_NETWORK: Active in about 3 s, invoke returns 200 with the handler's payload.
Check early with podman logs localstack | grep -i docker; the 'Creating Docker SDK client failed' DEBUG line at startup already tells you Lambda won't work.