---
title: "Discussion on \"🐳 Docker with Strapi V4 🌟\" | Hashnode"
description: "Discussion on \"🐳 Docker with Strapi V4 🌟\". Dockerize Strapi for development"
url: "https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [🐳 Docker with Strapi V4 🌟](https://blog.dehlin.dev/docker-with-strapi-v4?utm_source=hashnode&utm_medium=feed)

Dockerize Strapi for development

Jan 10, 2022 · 10 min read · blog.dehlin.dev  
Updated Jul 13, 2022  
Read the article

-   [#docker](https://hashnode.com/tag/docker)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#strapi](https://hashnode.com/tag/strapi)
-   [#docker-compose](https://hashnode.com/tag/docker-compose)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Simen Daehlin](https://hashnode.com/@eventyret)

@eventyret · United Kingdom

  
[View profile](https://hashnode.com/@eventyret)

Coding made easy

Software Engineer @Luno 🚀 JS/TS and Docker enthusiast

## Responses 19

Markdown supported · ⌘↵ to post

[Zahra Mahmood](https://hashnode.com/@zm98)

[Mar 7, 2025](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/67cb1fc8635a4cd6065e5dc0)

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?

[Emanuel Vidal](https://hashnode.com/@EmanuelVidal)

[Sep 21, 2023](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/650cb116721e3f2693c449b2)

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?

[Nabeel Shakeel](https://hashnode.com/@nabeel8)

[Sep 15, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6322d01007b36072368a03f7)

Hi [Simen Daehlin](https://hashnode.com/@eventyret), 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"]
```

[Simen Daehlin](https://hashnode.com/@eventyret)

[Sep 15, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6322d01007b36072368a03f7#reply-6322d37d776a69866dd6d3ac)

Thanks the idea is not to move node modules into it as it gives more attack surface, but will re-test it. Did you try the npx tool I created which auto creates the files etc as needed?

[Nabeel Shakeel](https://hashnode.com/@nabeel8)

[Sep 15, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6322d01007b36072368a03f7#reply-6322d482776a69866dd6d3e1)

[Simen Daehlin](https://hashnode.com/@eventyret) Yes, I used your tool to create Dockerfile and docker-compose.

When I moved node\_modules into `/opt/app` then it works because error is

```
error: Could not load js config file /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js
```

[Lukas Mayr](https://hashnode.com/@malua)

[Aug 31, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/630f6da156df9e8e50259627)

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

[Simen Daehlin](https://hashnode.com/@eventyret)

[Aug 31, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/630f6da156df9e8e50259627#reply-630f6e1575af73ad1f061507)

Not to sure how much it will be with the tutorial. But not working while in a container might be that you have to expose the ports to allow sending emails.

When it comes to default sender etc, i think you can pass variables into it, but by default there is none i think

[Lukas Mayr](https://hashnode.com/@malua)

[Aug 31, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/630f6da156df9e8e50259627#reply-630f771775af73ad1f061718)

Thanks for the fast response. I figured it out. I did not put all env variables into the task definition on aws.

[Igor Frolov](https://hashnode.com/@warmrobot)

[Aug 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62ef682ce3a3793580e022d1)

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.

[Simen Daehlin](https://hashnode.com/@eventyret)

[Aug 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62ef682ce3a3793580e022d1#reply-62ef80bbba649046e8d8f38b)

Hello [Igor Frolov](https://hashnode.com/@warmrobot) For `npm` you want to use `npm start` it's part of NPM hence why it doesn't need a script command in `package.json` this is if you want to override it.

`npm start` will start in production

[Jens](https://hashnode.com/@jensn)

[Aug 1, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62e7ee8a430bd1d04a8476be)

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.

[Simen Daehlin](https://hashnode.com/@eventyret)

[Aug 3, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62e7ee8a430bd1d04a8476be#reply-62ea33e116f9480a9dac4efb)

So in very simple terms. It's because it minimized attack surface of a container.

Think of it in this scenario. `node_modules` where your web browser / server is running it can be exploited. Meaning I can get access to the container and I can go up the chain.

If it's OUTSIDE, I get fewer exploits and have to go up further again.

[Rich Bernhardt](https://hashnode.com/@RichBern)

[Jul 12, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62cd5e093ba400c1d12e50c0)

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).

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jul 12, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62cd5e093ba400c1d12e50c0#reply-62cd5f098e6c0fc1acab40f6)

Hello [Rich Bernhardt](https://hashnode.com/@RichBern) 👋 So I have many times, it really depends how you setup the project.

If you are ONLY using the `Dockerfile` and not docker compose, you will need to change the `.env` and also expose the correct port in `Dockerfile` under EXPOSE.

IF you are using `docker-compose` you still need to PASS port into as a variable, as I don't think the file is doing it

```
...
 environment:
      PORT:   ${PORT}
port:
  - "${PORT}:${PORT}"
```

Else docker-compose won't have access to the environmental variable etc. In docker-compose I also normally then just do

```
port:
  - "${PORT}:1337"
```

That way I can control it what the OUT port is and not what strapi uses by default I just proxy it to my own port.

[Rich Bernhardt](https://hashnode.com/@RichBern)

[Jul 12, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62cd5e093ba400c1d12e50c0#reply-62cd72808e6c0fc1acab447c)

[Simen Daehlin](https://hashnode.com/@eventyret) Many thanks Simen, for your prompt response.

The extra line in environment `PORT: ${PORT}` didn't help, but extending the "strapi::cors" value in config > middlewares.js did solve the issue, although this forum does not allow me to share it.

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jul 12, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62cd5e093ba400c1d12e50c0#reply-62cdb01a24f934c8169852cb)

[Rich Bernhardt](https://hashnode.com/@RichBern) Oh that is good, if you want to send me a DM on discord find Eventyret on Strapi Discord server and I can try update the guide with what you did

[Niall](https://hashnode.com/@classicniall)

[Jul 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62c6e5ee39e2d97f4eaacc28)

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?

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jul 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62c6e5ee39e2d97f4eaacc28#reply-62c6e69939e2d97f4eaacc48)

Well only idea i can think of is that if you are using sqlite, permissions in windows and linux are different. BUT if it's built on each machine it should work fine tbh,

Seems to be maybe an issue with the setup or what you are connecting to rather then docker or your machine.

[Niall](https://hashnode.com/@classicniall)

[Jul 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62c6e5ee39e2d97f4eaacc28#reply-62c6ea64353b847f29e88fae)

[Simen Daehlin](https://hashnode.com/@eventyret) I switched it to MySQL (copying the guide), but I'm thinking that "platform" may be an issue (it's the only thing I can think of since it says "linux").

Could it be because I didn't run the initial strapi setup? I'd just assume that since all the files were created and committed, nothing else was needed. The only thing I had to re-create was the .env file.

So, an update. Docker Compose doesn't work. I've just booted up the Ubuntu machine, ran docker-compose up -d and I'm getting "server wasn't able to start properly" message, "error: knex: run".

This is a different error than on Windows, and I know Docker Desktop works, as I've been able to quickly spin up a WordPress site.

Funnily enough, the quickstart worked fine.

[Chap](https://hashnode.com/@chapdaddy65)

[Jun 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/629f773435465b6263092c0a)

```
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
```

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jun 8, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/629f773435465b6263092c0a#reply-62a071d73e84266b46094c4e)

I think this is in strapi and not You also are using postgresDB as a link but I think this was depricated in 3 you want to use volumes instead. Else strapi won't know where the data is etc.

[Chap](https://hashnode.com/@chapdaddy65)

[Jun 8, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/629f773435465b6263092c0a#reply-62a08cdf3e84266b46094fc7)

[Simen Daehlin](https://hashnode.com/@eventyret)

So Postgres loads up fine now, so that's fixed. But I still get the `cannot find module: ../data/data` error within strapi. I'm still looking for any other file that would be causing this but im still confused.

```
version: "3.8"

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:
    #   - postgres:postgres
    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:
      - postgres

  postgres:
    image: postgres:latest
    container_name: postgres
    # 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/
      - pgdata:/var/lib/postgresql/data
      - pgconf:/etc/postgresql
      - pglog:/var/log/postgresql
    ports:
      - "5432:5432"
    networks:
      - strapi

networks:
  strapi:
    name: strapi
    driver: bridge

volumes:
  pgdata:
    driver: local
  pgconf:
    driver: local
  pglog:
    driver: local
```

[Bohan Zhang](https://hashnode.com/@bohanzhang)

[May 27, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6290576e8826d59c309dce13)

`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"]
```

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jun 8, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6290576e8826d59c309dce13#reply-62a071f53e84266b46094c52)

Going to do a update of the Docker file and Docker-compose file shortly.

[alon borin](https://hashnode.com/@Balon)

[Apr 25, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/626681bad82f4558aff8cba6)

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?

[Simen Daehlin](https://hashnode.com/@eventyret)

[Apr 25, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/626681bad82f4558aff8cba6#reply-6266823b5dd5677e9b8e07bc)

Did you mount it or does the `data` folder exist you are trying to bind mount it to ?

[alon borin](https://hashnode.com/@Balon)

[Apr 25, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/626681bad82f4558aff8cba6#reply-626682e35dd5677e9b8e07ef)

[Simen Daehlin](https://hashnode.com/@eventyret) Can you please clarify? I didn't understand the question

[Simen Daehlin](https://hashnode.com/@eventyret)

[May 3, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/626681bad82f4558aff8cba6#reply-6270faa89ed78401a64093fb)

Sorry for a lte reply [alon borin](https://hashnode.com/@Balon) Did you create the folder "data" it looks to me like you are trying to mount `/data/myproject/data` so this means the `data` folder needs to exist and be empty.

[欧阳维杰](https://hashnode.com/@weijieouyang)

[Mar 25, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/623dd62ab6813c8a18c22482)

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.

[Nils K.](https://hashnode.com/@NKODING)

[Mar 21, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6238da016622115cc8048743)

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?

[Simen Daehlin](https://hashnode.com/@eventyret)

[Mar 21, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6238da016622115cc8048743#reply-6238dba96622115cc8048775)

[Nils K.](https://hashnode.com/@NKODING) Check what your url is set in the env setup.

[Nils K.](https://hashnode.com/@NKODING)

[Mar 21, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6238da016622115cc8048743#reply-6238dd705df27d5ca212f280)

[Simen Daehlin](https://hashnode.com/@eventyret) Hi I already did and double-checked it: my .env (I omit the other values):

```
HOST=0.0.0.0
PORT=1337
URL='sub.domain.de&
```

and in my config/server.js:

```
module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  url : env('URL', 'sub.domain.de&),
  app: {
    keys: env.array('APP_KEYS'),
  },
});
```

I still get those 2 entries with the "wrong" localhost url and the API error. Can't create my admin user..

[Robert](https://hashnode.com/@rrgt19)

[Jun 23, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6238da016622115cc8048743#reply-62b4e50eb86f939ac81b1607)

[Nils K.](https://hashnode.com/@NKODING) I have the same issue. Admin panel is using localhost and not my custom url configured in the .env. I don't have a workaround yet. Also, I cannot build the admin panel inside the docker container due to an error. I have created an issue here: [forum.strapi.io/t/strapi-v4-build-and-cache-folde…](https://forum.strapi.io/t/strapi-v4-build-and-cache-folders-does-not-exists-inside-docker-container/19764)

[Usash](https://hashnode.com/@Usash)

[Feb 18, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620fe5e49375bf259a97b957)

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 ![1.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1645209040786/kCiqvawSS.png)

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 19, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620fe5e49375bf259a97b957#reply-621176b0e2db563535e36a6d)

According to the logs sharp hasn't been installed correctly. So if this Windows check the output. [Usash](https://hashnode.com/@Usash)

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 28, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620fe5e49375bf259a97b957#reply-621d1415c07e2ceec785ffd4)

What is inside your `.env` for host? [Usash](https://hashnode.com/@Usash)

[Nils K.](https://hashnode.com/@NKODING)

[Mar 17, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620fe5e49375bf259a97b957#reply-623330296647c71acb640140)

I needed to change the Dockerfile a bit (adding -y):

RUN apt-get update && apt-get install -y libvips-dev

and also yarn.lock was not found so I commented it out. But now I get more errors running the docker-compose up -d:

strapi | yarn run v1.22.17 strapi | $ strapi develop strapi | Knex: run strapi | $ npm install pg --save strapi | Cannot find module 'pg' strapi | Require stack: strapi | - /opt/node\_modules/knex/lib/dialects/postgres/index.js strapi | - /opt/node\_modules/knex/lib/knex-builder/internal/config-resolver.js strapi | - /opt/node\_modules/knex/lib/knex-builder/Knex.js strapi | - /opt/node\_modules/knex/lib/index.js strapi | - /opt/node\_modules/knex/knex.js strapi | - /opt/node\_modules/@strapi/database/lib/index.js strapi | - /opt/node\_modules/@strapi/strapi/lib/Strapi.js strapi | - /opt/node\_modules/@strapi/strapi/lib/index.js strapi | - /opt/node\_modules/@strapi/strapi/lib/commands/develop.js strapi | - /opt/node\_modules/@strapi/strapi/bin/strapi.js

[Usash](https://hashnode.com/@Usash)

[Feb 16, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620d035e7cf10d2765e2a056)

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.

![1.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1645019968100/YTgV-guQV.png)

![2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1645019974254/PdjhpKcDD.png)

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 16, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620d035e7cf10d2765e2a056#reply-620d042c25673f2740eea3ca)

You need `RUN apt-get update && apt-get install libvips-dev -y` note the `-y` to say yes to all.

[Manuel](https://hashnode.com/@Manuel187)

[Feb 9, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6203dfc69e350308247fb860)

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?

[Manuel](https://hashnode.com/@Manuel187)

[Feb 10, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6203dfc69e350308247fb860#reply-620507e79e350308247fd268)

[Manuel](https://hashnode.com/@Manuel187) Ok do I don't know if this solution is the right way but I got it working. So for all those who have a similar problem. I have added the following line to my Strapi service:

```
strapi:
      ...
      volumes:
        - strapi:/opt/app/src
```

And created an additional volume in my docker-compose:

```
volumes:
  strapi:
```

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 11, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6203dfc69e350308247fb860#reply-62062de4a2be760e35393a65)

[Manuel](https://hashnode.com/@Manuel187) That is a good workaround indeed. You can mount the whole project into the container too. Creating it's separate volume will work as well. Though if files change you won't get a reflection on it in the container.

If you need a reflection, bind the folders to the same folders in the container.

```
strapi:
        ...
        volumes:
          - config:/opt/app/config
```

As though avoiding mounting node\_modules. If your system is different to linux.

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 17, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6203dfc69e350308247fb860#reply-620ea0bad589905b41291259)

Sorry for a bit of late reply [Manuel](https://hashnode.com/@Manuel187) If you docker-compose up again I think you need to do --build again to rebuild the image would that not be worth it ?

[DMehaffy (Strapi)](https://hashnode.com/@DMehaffy)

[Feb 8, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6202ffdb457dec06830c8c8f)

`strapi-connector-bookshelf`

You won't need this on v4 as it no longer exists.

[kalle](https://hashnode.com/@anka)

[Feb 9, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/6202ffdb457dec06830c8c8f#reply-620352b5b6c216065a35a924)

Yeah, I did my install without the quickflag and choose pg as db

[Dom](https://hashnode.com/@DomDew)

[Feb 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620190a73a8a6e5fe119a76d)

[Simen Daehlin](https://hashnode.com/@eventyret) thank you for this awesome Guide!

I got some of the same errors [kalle](https://hashnode.com/@anka) 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.

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 8, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/620190a73a8a6e5fe119a76d#reply-6202e0bbb6c216065a35a149)

Thanks for looking into it. I think that it is because there is no POSTGRES\_DB that is defined. Also I think that we can use FROM node:14 or node:14-alpine. Don't recommend alpine images for development but yes indeed for production.

did a minor update on the files etc.

[kalle](https://hashnode.com/@anka)

[Feb 5, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fec0adfd8b083e5728cf99)

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

[kalle](https://hashnode.com/@anka)

[Feb 9, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fec0adfd8b083e5728cf99#reply-62035315b6c216065a35a92d)

[Simen Daehlin](https://hashnode.com/@eventyret)

{ "name": "docker-strapi-ps", "private": true, "version": "0.1.0", "description": "A Strapi application", "scripts": { "develop": "strapi develop", "start": "strapi start", "build": "strapi build", "strapi": "strapi" }, "devDependencies": {}, "dependencies": { "@strapi/strapi": "4.0.7", "@strapi/plugin-users-permissions": "4.0.7", "@strapi/plugin-i18n": "4.0.7", "pg": "8.6.0" }, "author": { "name": "A Strapi developer" }, "strapi": { "uuid": "40a2ddf2-fcc4-4f67-b1e6-1360678a556f" }, "engines": { "node": ">=12.x.x <=16.x.x", "npm": ">=6.0.0" }, "license": "MIT" }

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 9, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fec0adfd8b083e5728cf99#reply-620368e7b6c216065a35ab76)

[kalle](https://hashnode.com/@anka) That's your package.json not your docker-compose file 😂😊

[kalle](https://hashnode.com/@anka)

[Feb 10, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fec0adfd8b083e5728cf99#reply-6204d5679e350308247fcc00)

[Simen Daehlin](https://hashnode.com/@eventyret) sorry :) heres the docker-compose file:

version: "3" services: strapi: container\_name: strapi build: . image: mystrapi: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:12.0-alpine container\_name: postgresDB restart: unless-stopped env\_file: .env environment: POSTGRES\_USER: ${DATABASE\_USERNAME} POSTGRES\_PASSWORD: ${DATABASE\_PASSWORD} volumes:

```
  - ./data:/var/lib/postgresql/data/
ports:
  - "5432:5432"
networks:
  - strapi
```

networks: strapi: name: Strapi driver: bridge

[Mincheol Kim](https://hashnode.com/@Universe)

[Feb 4, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fceb27fd8b083e5728a504)

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?

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 5, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fceb27fd8b083e5728a504#reply-61feba48fd8b083e5728cf15)

[Mincheol Kim](https://hashnode.com/@Universe)

So it's two things here. Sharp gets compiled, and uses this in the container so installing sharp on your mac should allow the container to build it.

If you need it inside the container, you can add

```
RUN apt-get update && apt-get install libvips libvips-dev -y
```

This is the line after `from node...` What you wrote in previous does an upgrade and update not installing the package.

[Mincheol Kim](https://hashnode.com/@Universe)

[Feb 7, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fceb27fd8b083e5728a504#reply-6200b1853a8a6e5fe1198a3b)

[Simen Daehlin](https://hashnode.com/@eventyret)

Unfortunately, the same error occurred when installed in my m1 MacBook, and the same problem continued when installed in the container.

I solved it by entering the command

```
platform: linux/amd64
```

in the docker-compose.yml file.

Thank you for the great guide!

[Camil Blanchet](https://hashnode.com/@cblanchet8)

[Feb 9, 2022](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/61fceb27fd8b083e5728a504#reply-620446a6b6c216065a35c3f7)

[Mincheol Kim](https://hashnode.com/@Universe)

Experiencing same issue but in Development Docker image build - did you find a work-around for that?
