3

I'm running docker for mac and I'm using a docker file. I'm also using a docker-compose file to create a mysql docker instance and a sam local instance on the same bridge network.

I was able to copy over my files to the sam local instance and get the mysql instance up and running.

When I do a docker-compose --build

I get the following error when I hit any endpoint on the API: Error invoking nodejs6.10 runtime: Error response from daemon: Minimum memory limit allowed is 4MB

when I execute this using sam local without the docker-compose or docker files inside of just my project folder. I don't get this issue.

From what I can tell, this comes from the underlying linux vm that docker for mac runs. These containers are LXC containers and they require a minimum memory of 4mb.

If I run this image using:

docker run -it --memory-reservation 10000000 -v /var/run/docker.sock:/var/run/docker.sock -p 3000:3000 samlocal

I still get this issue, which is what leads me to believe this is an issue in instantiating new lambda containers within sam local.

I'm not sure if there is a way to modify the hostconfig file for LXC from within the container or if there is some other solution to this problem.

My samlocal dockerfile and docker-compose file's follow:

DOCKERFILE:

FROM alpine:3.6

ENV VERSION=0.2.4

RUN apk add --no-cache curl && \ curl -sSLO https://github.com/awslabs/aws-sam-local/releases/download/v${VERSION}/sam_${VERSION}_linux_386.tar.gz && \ tar -C /usr/local/bin -zxvf /sam_${VERSION}_linux_386.tar.gz && \ apk del curl && \ rm -f /sam_${VERSION}_linux_386.tar.gz

RUN apk add --no-cache py-pip && pip install awscli

WORKDIR /var/opt

EXPOSE 3000

COPY . .

ENTRYPOINT ["/usr/local/bin/sam"] CMD ["local","start-api","--host", "0.0.0.0","--docker-volume-basedir", "/1725_ecpo_lambda"]

DOCKER-COMPOSE FILE:

version: "3" services:

samlocal: build: context: ./ dockerfile: sam-local-docker.dockerfile ports: - "3000:3000" volumes: - /var/run/docker.sock:/var/run/docker.sock networks: - backend

db: build: context: ./ dockerfile: mysql-docker.dockerfile ports: - 3306:3306 volumes: - db-data:/var/lib/mysql - /var/run/docker.sock:/var/run/docker.sock networks: - backend

networks: backend:

volumes: db-data:

Gino J
  • 71
  • 1
  • 6

0 Answers0