Use the Docker CLI to pull this image
Strapi comes with two images:
strapi/strapi to create a new project or run a project on your host machine.
strapi/base to build a Dockerfile and create an image for your app.
This image allows you to create a new strapi project or run a project form your host machine. The default command that will run in your project is
When running this image, strapi will check if there is a project in the
/src/app folder of the container. If there is nothing then it will run the
strapi new command in the container /srv/app folder. You can create a new project by running this command.
docker run -it -p 1337:1337 -v `pwd`/project-name:/srv/app strapi/strapi
This command creates a project with an SQLite database. Then starts it on port
-v option creates a
project-name folder on your computer that will be shared with the docker container.
Once the project is created it will be available in this folder on your computer.
When creating a new project with this image you can pass database configurations to the
strapi new command.
DATABASE_CLIENTa database provider supported by Strapi: (sqlite, postgres, mysql ,mongo).
DATABASE_SSLboolean for SSL.
EXTRA_ARGSpass extra args to the
You can create a strapi project that will connect to a remote postgres database like so:
docker run -it \ -e DATABASE_CLIENT=postgres \ -e DATABASE_NAME=strapi \ -e DATABASE_HOST=0.0.0.0 \ -e DATABASE_PORT=5432 \ -e DATABASE_USERNAME=strapi \ -e DATABASE_PASSWORD=strapi \ -p 1337:1337 \ -v `pwd`/project-name:/srv/app \ strapi/strapi
You can also create projects using docker-compose. See examples of using these variables with docker-compose in the examples folder.
You can also use
strapi/strapi to run a project you already have created (or cloned for a repo) on your computer.
First make sure to delete the
node_modules folder if you have already installed your dependencies on your host machine. Then run:
cd my-project docker run -it -p 1337:1337 -v `pwd`:/srv/app strapi/strapi
This will start by installing the dependencies and then run
strapi develop in the project.
If you are using environment variables in your code you can pass them with the -e option (e.g
docker run -e ENV_VAR=sth ...).
You can for example set your database configuration with envrionment variables.
Because the default container command is
strapi develop you will need to update your
development database configuration following the
production example in the documentation. Then you can run:
docker run -it \ -e DATABASE_NAME=strapi \ -e DATABASE_HOST=0.0.0.0 \ -e DATABASE_PORT=1234 \ -e DATABASE_USERNAME=strapi \ -e DATABASE_PASSWORD=strapi \ -p 1337:1337 \ -v `pwd`/project-name:/srv/app \ strapi/strapi
When deploying a strapi application to production you can use docker to package your whole app in an image. You can create a Dockerfile in your strapi project like the one in
You can build the images with the build command. To see the options run: