Running Strapi in a Docker container
Page summary:
This page guides you through running Strapi in Docker containers for development and production environments, including Dockerfile examples, Docker Compose configurations, and troubleshooting common issues.
Strapi does not build any official container images. The following instructions are provided as a courtesy to the community. If you have any questions please reach out on Discord.
Containerizing Strapi makes the runtime environment reproducible across machines and simplifies dependency management for deployment. This page covers building custom Docker images for an existing Strapi 5 project, with separate instructions for development and production environments, a troubleshooting section, and a list of community tools. If you would rather not write your own Dockerfile, see Community tools and images for packaged alternatives.
- Docker installed on your machine
- Docker Compose v2 or later
- A supported version of Node.js
- An existing Strapi 5 project, or a new one created with the Quick Start guide
- npm as your package manager (the examples on this page use npm, but you can adapt the commands for yarn or pnpm)
Development environment
Development images use npm run develop and mount your local source code for hot-reload. Before creating the Dockerfile, set up 2 required files: .dockerignore and .env.
Create a .dockerignore file
A .dockerignore file prevents local files from being copied into the Docker image. Without it, your local node_modules directory gets included in the build context, which causes architecture mismatches (e.g., x64 binaries on ARM) and increases the image size.
Create a .dockerignore file at the root of your Strapi project:
node_modules/
.tmp/
.cache/
.git/
build/
.env