Nice tutorial, helped me a ton! But, Im having some issues with my current strapi database(sqlite). I've exported the .tar file using strapi export, but when I try to run strapi import inside the docker container it says strapi doesnt have permissions for the public folder. How can I fix this?
Hi Simen Daehlin, Thanks for the wonderful article. It helps me a lot in setting up development environment on docker suing Strapi v4.
I was facing this error when using this Dockerfile to start starpi:
tw-backend | yarn run v1.22.19
tw-backend | $ strapi develop
tw-backend | Starting the compilation for TypeScript files in /opt/app
tw-backend | [2022-09-15 06:19:31.420] debug: βοΈ Server wasn't able to start properly.
tw-backend | [2022-09-15 06:19:31.423] error: Could not load js config file /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js:
tw-backend | Something went wrong installing the "sharp" module
tw-backend |
tw-backend | Cannot find module '../build/Release/sharp-linuxmusl-x64.node'
So, I solved this issue by by doing these two changes, move node_modules into opt/app and add install sharp
Adding my Dockerfile to save time for those who are facing the same issue
FROM node:16-alpine
# Installing libvips-dev for sharp Compatability
RUN apk update && apk add build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/app
COPY ./package.json ./yarn.lock ./
# ENV PATH /opt/node_modules/.bin:$PATH
RUN yarn config set network-timeout 600000 -g && yarn install
RUN yarn add --verbose --platform=linuxmusl --arch=x64 sharp
# WORKDIR /opt/app
COPY ./ .
RUN yarn build
EXPOSE 1337
CMD ["yarn", "develop"]
Hey Simen, thanks for the great tutorial. I got the server running on AWS ECS.
The only thing thats not working is sending mails. It works when I develop with strapi develop (without docker), but once it's inside a docker container, the email sending stops working. I am sending with nodemailer over Mandrill, which as I said works as long as it is not in the docker container.
In docker also the "default sender email" and the "default response email" are missing, although they are configured are also shown when developing.
If you have any insight, i would greatly appreciate an answer! all the best, lukas
Hello and thanks for this detailed tutorial!
One question: should we use npm start on production instead of npm run develop? I can't see package.json, so I don't understand what strapi command executed under the hood.
Thanks for the tutorial. One thing I do not understand is the following: What's the point of having the package.json (and package-lock.json) in /opt/? Instead of just having it in /opt/app/ like the rest.
Hi Simen
Many thanks for this post.
Just one question. I've tried to change the port number with no success. Have you ever managed to serve dockerized strapi v4 on a port other than 1337? If so, have you employed anything else on top of the below settings?
.env
PORT=3024
docker-compose.yml
...
ports:
- "${PORT}:${PORT}"
...
I've changed both side of the ports' config as strapi runs on the port set in .env.
Following start strapi, the login panel shows up, but clicking the log in button returns with internal server error (500).
Hi, thanks for the tutorial, it has helped me understand quite a bit.
I have tried this on an Ubuntu machine using Yarn, and it works straight away without issue. I then commited those changes to a repo and then clone it on to a Windows machine with NPM and Docker Desktop.
Everything seems to build just fine, I can see the images and the container with both "web" and DB. However, the web image is stuck in a restart loop due to some error of connecting to the DB (like it's the wrong credentials/permissions).
Any idea?
yarn run v1.22.19
$ strapi develop
debug: βοΈ Server wasn't able to start properly.
error: Cannot find module '../data/data'
Not sure why it thinks to look for data within data, I only wanted to test it working on the latest image of Postgres, otherwise it's identical. here's my docker-compose.yml:
version: "3"
services:
strapi:
container_name: strapi
build: .
image: strapi:latest
# restart: unless-stopped
env_file: .env
environment:
DATABASE_CLIENT: ${DATABASE_CLIENT}
DATABASE_HOST: postgresDB
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USERNAME: ${DATABASE_USERNAME}
DATABASE_PORT: ${DATABASE_PORT}
JWT_SECRET: ${JWT_SECRET}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
NODE_ENV: ${NODE_ENV}
links:
- postgresDB:postgresDB
volumes:
- ./config:/opt/app/config
- ./src:/opt/app/src
- ./package.json:/opt/package.json
- ./yarn.lock:/opt/yarn.lock
- ./.env:/opt/app/.env
ports:
- "1337:1337"
networks:
- strapi
depends_on:
- postgresDB
postgresDB:
image: postgres:latest
container_name: postgresDB
# restart: unless-stopped
env_file: .env
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- ./data:/var/lib/postgresql/data/
ports:
- "5432:5432"
networks:
- strapi
networks:
strapi:
name: strapi
driver: bridge
yarn.lock does not exist
β StrapiServerless docker build -t mystrapi:latest .
[+] Building 17.0s (9/14)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for docker.io/library/node:16 16.9s
=> [internal] load build context 0.0s
=> => transferring context: 12.87kB 0.0s
=> CANCELED [ 1/10] FROM docker.io/library/node:16@sha256:32605ead97ed57bd39a8a7b0e919240e1a3218974dfc6965e61b54a801753131 0.0s
=> => resolve docker.io/library/node:16@sha256:32605ead97ed57bd39a8a7b0e919240e1a3218974dfc6965e61b54a801753131 0.0s
=> => sha256:b025e782e09fa7e1cdfab96049de130c27dd8d641c5220335d5905760e62c53f 7.62kB / 7.62kB 0.0s
=> => sha256:32605ead97ed57bd39a8a7b0e919240e1a3218974dfc6965e61b54a801753131 1.21kB / 1.21kB 0.0s
=> => sha256:085b1865ac9604641514610a340c6490b4c641b7370b00a75686f5bff8971688 2.21kB / 2.21kB 0.0s
=> CACHED [ 2/10] RUN apt-get update && apt-get install libvips-dev 0.0s
=> CACHED [ 3/10] WORKDIR /opt/ 0.0s
=> CACHED [ 4/10] COPY ./package.json ./ 0.0s
=> ERROR [ 5/10] COPY ./yarn.lock ./ 0.0s
------
> [ 5/10] COPY ./yarn.lock ./:
------
failed to compute cache key: "/yarn.lock" not found: not found
and after I comment this line I found your Dockerfile in line 3 forget to add -y for argee install, here is my Dockerfile
FROM node:16
# Installing libvips-dev for sharp compatability
RUN apt-get update && apt-get install -y libvips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY ./package.json ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN yarn config set network-timeout 600000 -g
RUN yarn install
WORKDIR /opt/app
COPY ./ .
RUN yarn build
EXPOSE 1337
CMD ["yarn", "develop"]
Thanks for the guide. After running docker-compose up -d I get the following error:
ERROR: for postgresDB Cannot start service postgresDB: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/data/myproject/data" to rootfs at "/var/lib/postgresql/data" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for postgresDB Cannot start service postgresDB: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/data/myproject/data" to rootfs at "/var/lib/postgresql/data" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
did anyone get anything similar and solved this?
Can not run "yarn develop" as the files in './data' directory keeps changing after the postgresDB service started. This will make the strapi constantly restarting. So I have to move the './data' directory to another position.
Instead of node:16 I used node:14 and also I am using npm not yarn. I am using this Dockerfile (which is just a bit different from yours):
FROM node:14
# Installing libvips-dev for sharp compatability
RUN apt-get update && apt-get install -y libvips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY ./package.json ./
COPY ./package-lock.json ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN npm install
WORKDIR /opt/app
COPY ./ .
RUN npm build
EXPOSE 1337
CMD ["npm", "run", "develop"]
I added knex and pg as dev dependencies:
npm install pg knex --save-dev
Then I built my image like you did and spinned up the containers using docker-compose up -d. Everything is working fine for now and I see the "Create First Administrator" view. But if I click on that button I get a spinning icon and the error message "Warning: An error occurred while requesting the API" - nothing more. The logs show nothing unusual:
postgresDB | 2022-03-21 19:56:28.879 UTC [1] LOG: starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
postgresDB | 2022-03-21 19:56:28.879 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgresDB | 2022-03-21 19:56:28.879 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgresDB | 2022-03-21 19:56:28.883 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresDB | 2022-03-21 19:56:28.895 UTC [21] LOG: database system was shut down at 2022-03-21 19:56:22 UTC
postgresDB | 2022-03-21 19:56:28.900 UTC [1] LOG: database system is ready to accept connections
strapi |
strapi | > strapi-playground@0.1.0 develop /opt/app
strapi | > strapi develop
strapi |
strapi | Building your admin UI with development configuration ...
strapi | Admin UI built successfully
strapi |
strapi | Project information
strapi |
strapi | βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
strapi | β Time β Mon Mar 21 2022 19:56:33 GMT+0000 (Coordinated β¦ β
strapi | β Launched in β 799 ms β
strapi | β Environment β development β
strapi | β Process PID β 34 β
strapi | β Version β 4.1.5 (node v14.19.1) β
strapi | β Edition β Community β
strapi | βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
strapi |
strapi | Actions available
strapi |
strapi | One more thing...
strapi | Create your first administrator π» by going to the administration panel at:
strapi |
strapi | βββββββββββββββββββββββββββββββ
strapi | β http://localhost:1337/admin β
strapi | βββββββββββββββββββββββββββββββ
strapi |
strapi | [2022-03-21 19:56:34.039] http: GET index.html (19 ms) 200
strapi | [2022-03-21 19:56:34.130] http: GET /assets/images/logo_login.png (12 ms) 200
strapi | [2022-03-21 19:56:34.133] http: GET /assets/images/group_people_1.png (8 ms) 200
strapi | [2022-03-21 19:56:34.134] http: GET /assets/images/group_people_3.png (6 ms) 200
strapi | [2022-03-21 19:56:34.134] http: GET /assets/images/group_people_2.png (5 ms) 200
strapi | [2022-03-21 19:56:34.407] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 19:56:35.169] http: GET index.html (4 ms) 200
strapi | [2022-03-21 19:56:35.238] http: GET /assets/images/logo_login.png (2 ms) 200
strapi | [2022-03-21 19:56:35.247] http: GET /assets/images/group_people_1.png (4 ms) 200
strapi | [2022-03-21 19:56:35.247] http: GET /assets/images/group_people_2.png (3 ms) 200
strapi | [2022-03-21 19:56:35.248] http: GET /assets/images/group_people_3.png (3 ms) 200
strapi | [2022-03-21 19:56:35.514] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 19:56:36.048] http: GET index.html (4 ms) 200
strapi | [2022-03-21 19:56:36.117] http: GET /assets/images/group_people_1.png (4 ms) 200
strapi | [2022-03-21 19:56:36.117] http: GET /assets/images/logo_login.png (2 ms) 200
strapi | [2022-03-21 19:56:36.122] http: GET /assets/images/group_people_2.png (2 ms) 200
strapi | [2022-03-21 19:56:36.130] http: GET /assets/images/group_people_3.png (2 ms) 200
strapi | [2022-03-21 19:56:36.326] http: GET index.html (3 ms) 200
strapi | [2022-03-21 19:56:36.526] http: GET index.html (3 ms) 200
strapi | [2022-03-21 19:56:36.698] http: GET index.html (4 ms) 200
strapi | [2022-03-21 19:56:36.878] http: GET index.html (3 ms) 200
strapi | [2022-03-21 19:56:37.048] http: GET index.html (3 ms) 200
strapi | [2022-03-21 19:56:37.417] http: GET index.html (3 ms) 200
strapi | [2022-03-21 19:56:37.597] http: GET index.html (4 ms) 200
strapi | [2022-03-21 19:56:37.778] http: GET index.html (4 ms) 200
strapi | [2022-03-21 19:56:37.946] http: GET index.html (3 ms) 200
strapi | [2022-03-21 19:56:38.139] http: GET index.html (4 ms) 200
strapi | [2022-03-21 19:56:38.208] http: GET /assets/images/group_people_2.png (5 ms) 200
strapi | [2022-03-21 19:56:38.209] http: GET /assets/images/group_people_3.png (5 ms) 200
strapi | [2022-03-21 19:56:38.210] http: GET /assets/images/group_people_1.png (3 ms) 200
strapi | [2022-03-21 19:56:38.210] http: GET /assets/images/logo_login.png (3 ms) 200
strapi | [2022-03-21 19:56:38.473] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 19:56:50.981] http: GET /admin (3 ms) 200
strapi | [2022-03-21 19:56:55.216] http: GET /admin (2 ms) 200
strapi | [2022-03-21 19:56:55.275] http: GET /admin/main.25a14c1f.js (2 ms) 200
strapi | [2022-03-21 19:56:55.276] http: GET /admin/runtime~main.385dfcf4.js (2 ms) 200
strapi | [2022-03-21 19:56:56.618] http: GET /admin/1856.a30bd09b.chunk.js (2 ms) 200
strapi | [2022-03-21 19:56:56.628] http: GET /admin/497.3fcf6196.chunk.js (4 ms) 200
strapi | [2022-03-21 19:56:56.628] http: GET /admin/1454.f065d92a.chunk.js (3 ms) 200
strapi | [2022-03-21 19:56:56.629] http: GET /admin/4362.cf5b578d.chunk.js (2 ms) 200
strapi | [2022-03-21 19:56:56.760] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 19:56:56.777] http: GET /admin/fontawesome-css.36cff9ae.chunk.js (1 ms) 200
strapi | [2022-03-21 19:56:56.784] http: GET /admin/en-json.2bc27a3d.chunk.js (1 ms) 200
strapi | [2022-03-21 19:56:56.785] http: GET /admin/fr-json.a9ce0700.chunk.js (1 ms) 200
strapi | [2022-03-21 19:56:56.854] http: GET /admin/email-translation-en-json.fa0dc92b.chunk.js (5 ms) 200
strapi | [2022-03-21 19:56:56.855] http: GET /admin/content-type-builder-translation-fr-json.bee621f7.chunk.js (3 ms) 200
strapi | [2022-03-21 19:56:56.855] http: GET /admin/fontawesome-css-all.3b89f909.chunk.js (4 ms) 200
strapi | [2022-03-21 19:56:56.856] http: GET /admin/content-type-builder-translation-en-json.8034dab6.chunk.js (3 ms) 200
strapi | [2022-03-21 19:56:56.859] http: GET /admin/email-translation-fr-json.49c3c888.chunk.js (2 ms) 200
strapi | [2022-03-21 19:56:56.876] http: GET /admin/i18n-translation-en-json.4d823f62.chunk.js (14 ms) 200
strapi | [2022-03-21 19:56:56.876] http: GET /admin/upload-translation-en-json.c334dd82.chunk.js (13 ms) 200
strapi | [2022-03-21 19:56:56.877] http: GET /admin/upload-translation-fr-json.1bec79ec.chunk.js (13 ms) 200
strapi | [2022-03-21 19:56:56.877] http: GET /admin/i18n-translation-fr-json.c6367bc9.chunk.js (13 ms) 200
strapi | [2022-03-21 19:56:56.877] http: GET /admin/users-permissions-translation-en-json.21b0fd2f.chunk.js (12 ms) 200
strapi | [2022-03-21 19:56:56.879] http: GET /admin/users-permissions-translation-fr-json.a2172545.chunk.js (4 ms) 200
strapi | [2022-03-21 19:56:56.944] http: GET /admin/fontawesome-js.2639263c.chunk.js (2 ms) 200
strapi | [2022-03-21 19:56:57.162] http: GET /admin/b997a22a2e0b87ef1fa2.ico (1 ms) 200
strapi | [2022-03-21 19:56:57.427] http: GET /admin/cropper-css.ace19575.chunk.js (2 ms) 200
strapi | [2022-03-21 19:57:00.538] http: GET /admin (2 ms) 200
strapi | [2022-03-21 19:57:00.597] http: GET /admin/runtime~main.385dfcf4.js (1 ms) 200
strapi | [2022-03-21 19:57:00.604] http: GET /admin/main.25a14c1f.js (1 ms) 200
strapi | [2022-03-21 19:57:01.902] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 19:57:02.817] http: GET /admin/1856.a30bd09b.chunk.js (1 ms) 200
strapi | [2022-03-21 19:57:02.828] http: GET /admin/497.3fcf6196.chunk.js (4 ms) 200
strapi | [2022-03-21 19:57:02.829] http: GET /admin/1454.f065d92a.chunk.js (4 ms) 200
strapi | [2022-03-21 19:57:02.830] http: GET /admin/4362.cf5b578d.chunk.js (3 ms) 200
strapi | [2022-03-21 19:57:03.102] http: GET /admin/fontawesome-css.36cff9ae.chunk.js (1 ms) 200
strapi | [2022-03-21 19:57:03.109] http: GET /admin/fr-json.a9ce0700.chunk.js (4 ms) 200
strapi | [2022-03-21 19:57:03.110] http: GET /admin/en-json.2bc27a3d.chunk.js (3 ms) 200
strapi | [2022-03-21 19:57:03.240] http: GET /admin/fontawesome-css-all.3b89f909.chunk.js (1 ms) 200
strapi | [2022-03-21 19:57:03.367] http: GET /admin/content-type-builder-translation-en-json.8034dab6.chunk.js (5 ms) 200
strapi | [2022-03-21 19:57:03.367] http: GET /admin/content-type-builder-translation-fr-json.bee621f7.chunk.js (4 ms) 200
strapi | [2022-03-21 19:57:03.368] http: GET /admin/upload-translation-fr-json.1bec79ec.chunk.js (4 ms) 200
strapi | [2022-03-21 19:57:03.372] http: GET /admin/i18n-translation-en-json.4d823f62.chunk.js (6 ms) 200
strapi | [2022-03-21 19:57:03.375] http: GET /admin/email-translation-en-json.fa0dc92b.chunk.js (6 ms) 200
strapi | [2022-03-21 19:57:03.377] http: GET /admin/email-translation-fr-json.49c3c888.chunk.js (6 ms) 200
strapi | [2022-03-21 19:57:03.380] http: GET /admin/i18n-translation-fr-json.c6367bc9.chunk.js (7 ms) 200
strapi | [2022-03-21 19:57:03.383] http: GET /admin/upload-translation-en-json.c334dd82.chunk.js (7 ms) 200
strapi | [2022-03-21 19:57:03.384] http: GET /admin/users-permissions-translation-en-json.21b0fd2f.chunk.js (6 ms) 200
strapi | [2022-03-21 19:57:03.384] http: GET /admin/users-permissions-translation-fr-json.a2172545.chunk.js (2 ms) 200
strapi | [2022-03-21 19:57:03.429] http: GET /admin/fontawesome-js.2639263c.chunk.js (1 ms) 200
strapi | [2022-03-21 19:57:03.819] http: GET /admin/b997a22a2e0b87ef1fa2.ico (1 ms) 200
strapi | [2022-03-21 19:57:04.929] http: GET /admin/cropper-css.ace19575.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:19.848] http: GET /admin (2 ms) 200
strapi | [2022-03-21 20:01:19.907] http: GET /admin/runtime~main.385dfcf4.js (1 ms) 200
strapi | [2022-03-21 20:01:19.914] http: GET /admin/main.25a14c1f.js (1 ms) 200
strapi | [2022-03-21 20:01:21.146] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 20:01:21.945] http: GET /admin/1856.a30bd09b.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:21.952] http: GET /admin/497.3fcf6196.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:21.953] http: GET /admin/1454.f065d92a.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:21.953] http: GET /admin/4362.cf5b578d.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:22.437] http: GET /admin/fontawesome-css.36cff9ae.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:22.443] http: GET /admin/fr-json.a9ce0700.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:22.444] http: GET /admin/en-json.2bc27a3d.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:22.518] http: GET /admin/fontawesome-css-all.3b89f909.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:22.595] http: GET /admin/content-type-builder-translation-en-json.8034dab6.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:22.614] http: GET /admin/email-translation-en-json.fa0dc92b.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:22.615] http: GET /admin/content-type-builder-translation-fr-json.bee621f7.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:22.615] http: GET /admin/email-translation-fr-json.49c3c888.chunk.js (4 ms) 200
strapi | [2022-03-21 20:01:22.619] http: GET /admin/i18n-translation-en-json.4d823f62.chunk.js (6 ms) 200
strapi | [2022-03-21 20:01:22.621] http: GET /admin/users-permissions-translation-en-json.21b0fd2f.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:22.622] http: GET /admin/users-permissions-translation-fr-json.a2172545.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:22.626] http: GET /admin/upload-translation-en-json.c334dd82.chunk.js (6 ms) 200
strapi | [2022-03-21 20:01:22.627] http: GET /admin/i18n-translation-fr-json.c6367bc9.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:22.628] http: GET /admin/upload-translation-fr-json.1bec79ec.chunk.js (3 ms) 200
strapi | [2022-03-21 20:01:22.665] http: GET /admin/fontawesome-js.2639263c.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:22.988] http: GET /admin/b997a22a2e0b87ef1fa2.ico (1 ms) 200
strapi | [2022-03-21 20:01:23.457] http: GET /admin/cropper-css.ace19575.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:30.351] http: GET /admin (2 ms) 200
strapi | [2022-03-21 20:01:30.416] http: GET /admin/runtime~main.385dfcf4.js (2 ms) 200
strapi | [2022-03-21 20:01:30.416] http: GET /admin/main.25a14c1f.js (1 ms) 200
strapi | [2022-03-21 20:01:31.778] http: GET /favicon.ico (0 ms) 200
strapi | [2022-03-21 20:01:32.246] http: GET /admin/1856.a30bd09b.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:32.257] http: GET /admin/4362.cf5b578d.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:32.258] http: GET /admin/497.3fcf6196.chunk.js (5 ms) 200
strapi | [2022-03-21 20:01:32.259] http: GET /admin/1454.f065d92a.chunk.js (3 ms) 200
strapi | [2022-03-21 20:01:32.426] http: GET /admin/fontawesome-css.36cff9ae.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:32.434] http: GET /admin/en-json.2bc27a3d.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:32.434] http: GET /admin/fr-json.a9ce0700.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:32.504] http: GET /admin/fontawesome-css-all.3b89f909.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:32.527] http: GET /admin/content-type-builder-translation-en-json.8034dab6.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:32.536] http: GET /admin/content-type-builder-translation-fr-json.bee621f7.chunk.js (4 ms) 200
strapi | [2022-03-21 20:01:32.536] http: GET /admin/email-translation-en-json.fa0dc92b.chunk.js (3 ms) 200
strapi | [2022-03-21 20:01:32.537] http: GET /admin/email-translation-fr-json.49c3c888.chunk.js (3 ms) 200
strapi | [2022-03-21 20:01:32.539] http: GET /admin/upload-translation-fr-json.1bec79ec.chunk.js (4 ms) 200
strapi | [2022-03-21 20:01:32.544] http: GET /admin/users-permissions-translation-en-json.21b0fd2f.chunk.js (6 ms) 200
strapi | [2022-03-21 20:01:32.548] http: GET /admin/i18n-translation-fr-json.c6367bc9.chunk.js (7 ms) 200
strapi | [2022-03-21 20:01:32.550] http: GET /admin/users-permissions-translation-fr-json.a2172545.chunk.js (3 ms) 200
strapi | [2022-03-21 20:01:32.552] http: GET /admin/upload-translation-en-json.c334dd82.chunk.js (3 ms) 200
strapi | [2022-03-21 20:01:32.553] http: GET /admin/i18n-translation-en-json.4d823f62.chunk.js (2 ms) 200
strapi | [2022-03-21 20:01:32.580] http: GET /admin/fontawesome-js.2639263c.chunk.js (1 ms) 200
strapi | [2022-03-21 20:01:32.854] http: GET /admin/b997a22a2e0b87ef1fa2.ico (2 ms) 200
strapi | [2022-03-21 20:01:33.196] http: GET /admin/cropper-css.ace19575.chunk.js (1 ms) 200
Do you know what could cause the problem?
After following all step by step my project run successfully in docker container. but I want to run strapi project locally by yarn develop command and the postgres will be run in docker container by docker-compose -d up postgresDB.
The Docker is completely fine and do his job as run postgresDB alone. but when i try yarn develop i got error and crash my project

I am new at Strapi. I want to dockerize my own strapi project which is created by --quickstart. I followed your tutorial step by step. but when I try to build Dockerfile by docker build -t mystrapi:latest . command it trying to install with a few minutes and then the error message shows
=> ERROR [ 2/10] RUN apt-get update && apt-get install libvips-dev
I'm using Docker Desktop on Windows.


Hi first off all thank you for this tutorial.
I guess i'm missing one last step.
I did everything exactly as described in the tutorial except that i don't have an build . in the docker compose but i push an image into my own container registry before it and then use that image.
So this is my docker-compose file:
version: '3'
services:
strapi:
container_name: strapi
image: ghcr.io/confidato/strapi-cms:latest
restart: unless-stopped
env_file: .env
environment:
DATABASE_CLIENT: ${DATABASE_CLIENT}
DATABASE_HOST: postgresDB
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USERNAME: ${DATABASE_USERNAME}
DATABASE_PORT: ${DATABASE_PORT}
JWT_SECRET: ${JWT_SECRET}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
NODE_ENV: ${NODE_ENV}
links:
- postgresDB:postgresDB
volumes:
- ./public:/public/upload
#- ./src:/opt/app/src ### If this line is not in the file it starts.
ports:
- "1337:1337"
depends_on:
- postgresDB
postgresDB:
image: postgres:12.0-alpine
container_name: postgresDB
restart: unless-stopped
env_file: .env
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- ./data:/var/lib/postgresql/data/
ports:
- "5432:5432"
networks:
default:
external:
name: network123
If i start it without the line - ./src:/opt/app/src in volumes everthing looks good but if i use docker-compose down my data won't show up again in the admin-dashboard. I guess i have a problem with my volume mapping. If I add the line - ./src:/opt/app/src strapi has an error at startup and it says: Missing api folder. Please create one at './src/api'.
Any idea where my problem is?
strapi-connector-bookshelf
You won't need this on v4 as it no longer exists.
Simen Daehlin thank you for this awesome Guide!
I got some of the same errors kalle was facing, as well as the error with the sharp dependency. For me running the container with an alpine image and adding some missing shared libraries did the trick.
What I did was replacing the FROM node:16 line with:
FROM node:16-alpine
RUN apk add --no-cache libc6-compat
Just leaving this here in case someone might need this.
Now while this did work splendidly on a fresh install of strapi v4 (again, thank you for this amazing guide!), weirdly enough, when I try to dockerize an existing strapi project (v.4.0.7) I get the error:
debug: βοΈ Server wasn't able to start properly. strapi error: password authentication failed for user "strapi"
all the same while the postgres container throws the error:
DETAIL: Role "strapi" does not exist.
I followed the steps in the update you just published, to no avail. Oddly enough, when I look at the container the postgres db is running in, all the env variables etc. seem to be set properly and recognized by the container. Do you have any idea by any chance what strange mysteries could be happening here?
Just a quick heads-up: strapi-connector-bookshelf needs a node version >=10.16.0 <=14.x.x to run. Should one need the dependency, then changing the first line in the Dockerfile to
FROM node:14
fixes this issue.
Hi Simen,
Thanks for your demo. I hade to change
docker-compose up -d postgresdb && yarn develop
to
docker-compose up -d strapi && yarn develop
as the .env as strapi as I get that
no such service: postgresdb
But my the error I am getting when running with
docker-compose up -d strapi && yarn develop
is the following:
debug: βοΈ Server wasn't able to start properly. error: The server does not support SSL connections
Have you run into this issue? I am on Mac OS Monterey v12.2 and node v 16.3.0
The
docker-compose up -d
is working without errors
Thank you for the detailed guide!
Unfortunately, it failed at the stage of creating a docker image. I'm using the m1 Silicon Mac Book. The error message is as follows.
sharp: Installation error: Use with glibc 2.28 requires manual installation of libvips >= 8.11.3
The docker node16 image can't be bullseye, before yarn install,
RUN apt-get update -y && \
apt-get upgrade -y libvips libvips-dev
Installing libvips with the above command failed with the same error message.
Is there a good way to solve it?
Zahra Mahmood
I'm getting this error when trying to run 'docker compose up' or docker compose up --build' :
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'strapi'@'172.18.0.3' (using password: YES)
Has anyone seen this before or know of a solution?