Run Gatsby with docker compose
My issue was that Gatsby was only listening to requests within the container, like this answer suggests. Make sure you've configured Gatsby for the host 0.0.0.0
. Take this (somewhat hacky) setup as an example:
Dockerfile
FROM node:alpineRUN npm install --global gatsby-cli
docker-compose.yml
version: "3.7"services: gatsby: build: context: . dockerfile: Dockerfile entrypoint: gatsby volumes: - .:/app develop: build: context: . dockerfile: Dockerfile command: gatsby develop -H 0.0.0.0 ports: - "8000:8000" volumes: - .:/app
You can run Gatsby commands from a container:docker-compose run gatsby info
Or run the development server:docker-compose up develop