How to run latest Strapi with docker?


I want to use latest Strapi with SQLite database in Docker container.

From tutorial I got this docker-compose.yaml:
version: ‘3’

    image: strapi/strapi
      - ./:/srv/app
      - '1337:1337'

But when I run it with docker-compose up creates all the files in same directory as docker-compose.yaml.

version: '3'
    image: strapi/strapi
      - ./tmp:/srv/app/.tmp
      - ./config:/srv/app/.config
      - ./public/uploads:/srv/app/public/uploads
      - '1337:1337'

But then I started to get error.:

strapi_1 | Using strapi 3.6.8
strapi_1 | No project found at /srv/app. Creating a new strapi project
strapi_1 | :no_entry: You can only create a Strapi app in an empty directory.
strapi_1 | Make sure /srv/app is empty.
strapi_strapi_1 exited with code 1

How do I make it so that this error is fixed and docker-compose.yaml directory is not littered with with all those files? So that all files are inside docker and only SQLite database is persisted outside of docker to avoid it getting deleted with docker restart? Also it seems to be Strapi 3.6.8? But version 4 is out. Is there way to get version 4? Also do I still need Dockerfile if this docker-compose.yaml seems to make it all already?

You can use the tool i built for this

Just run

npx @strapi-community/dockerize

Note the image you are using is for V3 and won’t work for V4.
Also please note it’s HIGLY not recommended to use SQLITE for Docker as everytime you kill the container you will delete the database, unless you bind mount.

The tool I created can spin up Mysql / MariaDB or postgres databases locally so you can use it for testing.


There is no way to have just docker-compose file? Using SQLite by binding mount is bad practise?

Anyways with that command I ran into errors:

osboxes@osboxes:~/strapi$ npx @strapi-community/dockerize

Need to install the following packages:


Ok to proceed? (y) y

npm WARN EBADENGINE Unsupported engine {

npm WARN EBADENGINE   package: 'liquidjs@10.4.0',

npm WARN EBADENGINE   required: { node: '>=14' },

npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }



  throw err;


Error: Cannot find module 'fs/promises'

Require stack:

- /home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/utils/utils.js

- /home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/utils/goodbye.js

- /home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/utils/index.js

- /home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/cli/quickstart.js

- /home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/cli/index.js

- /home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/index.js

    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)

    at Function.Module._load (internal/modules/cjs/loader.js:667:27)

    at Module.require (internal/modules/cjs/loader.js:887:19)

    at require (internal/modules/cjs/helpers.js:74:18)

    at Object.<anonymous> (/home/osboxes/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/utils/utils.js:2:30)

    at Module._compile (internal/modules/cjs/loader.js:999:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

    at Module.load (internal/modules/cjs/loader.js:863:32)

    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

    at Module.require (internal/modules/cjs/loader.js:887:19) {


  requireStack: [










I also tried this on work computer today.

On windows 10
Command: npx @strapi-community/dockerize@latest


 @strapi-community/dockerize  v1.11.0 by Simen Daehlin                                 
Easy add docker support for a Strapi Project                                                                
�  You, and 755 other people have used this tool this month                            
�  JavaScript project detected                                                         
�  NPM detected                                                                        
⛔️  Strapi project not detected                                                        
√ Do you want to create a new Strapi Project ... No / Yes                              
√ Whats the name of the project? ... mystrapi                                          
√ Do you want to use TypeScript ... No / Yes                                           
�  Creating Strapi Project from npx create-strapi-app@latest - please wait...          
      throw er; // Unhandled 'error' event                                             
Error: spawn npx ENOENT                                                                
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)        
    at onErrorNT (node:internal/child_process:478:16)                                  
    at processTicksAndRejections (node:internal/process/task_queues:83:21)             
Emitted 'error' event on ChildProcess instance at:                                     
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)        
    at onErrorNT (node:internal/child_process:478:16)                                  
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {           
  errno: -4058,                                                                        
  code: 'ENOENT',                                                                      
  syscall: 'spawn npx',                                                                
  path: 'npx',                                                                         
  spawnargs: [                                                                         

When I try npx @strapi-community/dockerize (without latest at the end) I get the same error.

On WSL Ubuntu I get /usr/bin/env: ‘bash\r’: No such file or directory with this command

First please note
:no_entry: Strapi project not detected You need to create a strapi project first. then run the command inside that project.

For the error itself feel free to post this data on a issue and I can test it out or try get a fix for it as it’s a separate issue. Creating a new strapi project from the plugin is a bit of hit and miss and I will need more test data to fully fledge out bugs.

Ah ok, I understood this command will automatically create project.

It even asks

√ Do you want to create a new Strapi Project … No / Yes

But I still need to do it manually?I don’t have other information than just that I run this command inside empty directory.

What needs to be done then to get new Strapi Docker with SQLite database that is mapped outside of docker?

It’s just released and a bit buggy :slight_smile:

You can do it quite simply by run

npx create-strapi-app@latest my-project --quickstar

Then you can run the dockerize tool when it’s created

The whole idea with docker is to containerize it, so you want to use a propper database.
The docker-compose will ask you what you want to use and you can use a propper database instead.


That worked! But how do I turn this into docker container? It did not create any docker files.

So if you run the normal CLI to create a strapi application.
You can then use the Dockerize tool that you tried to use inside the strapi project.
It will ask you a bunch of questions answer them and it creates dockerfiles and a docker-compose file (if you say yes) for you. It also configures the database file to match the database you selected.

So technically run both tools and it should all be ready to go.

This one?

So that’s the blog i wrote about it yes :slight_smile:

So the steps you do

npx create-strapi-app@latest myproject --quickstart

This will create the project etc. Then stop it and make sure you are in the strapi directory myproject in this example
then run

npx @strapi-community/dockerize

Answer the questions you might want “both” and docker-compose
And you are good to go.

Here is the github for the tool

1 Like