---
title: "Comment by Rich Bernhardt on \"🐳 Docker with Strapi V4 🌟\" | Hashnode"
description: "Hi Simen Many thanks for this post. Just one question. I&#39;ve tried to change the port number with no success. Have you ever managed to serve dockerized strap"
url: "https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd/comment/62cd5e093ba400c1d12e50c0"
---

[Discussion](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd)

Comment [🐳 Docker with Strapi V4 🌟](https://hashnode.com/posts/docker-with-strapi-v4/61dcb820cda0d0294b69c3cd)

[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
