How to use `strapi develop --watch-admin` within a Docker container

System Information
  • Strapi Version: 3.6.8
  • Operating System: macOS
  • Database: MySQL 5.7
  • Node Version: 14.18.0
  • NPM Version: 6.14.15
  • Yarn Version: 1.22.15

I’m using Strapi on a Docker container and struggling to use the option --watch-admin. It looks like Strapi exposes port 8000 when --watch-admin is enabled but it cannot be accessed on the host machine even with port forwarding enabled. If I try accessing port 8000 inside the Strapi container, it succeeded. Is there any good way to use strapi develop --watch-admin with Docker? Thank you in advance.

I think this is a known issue with docker and strapi.
Workaround would be to just use docker to spin up a database and run --watch-admin locally

1 Like


Thank you for your reply. I’m really sorry for my slow response.

I see. I’ll use --watch-admin by running Strapi locally… Thanks!

Any luck?
I can’t get it to work locally at all

1 Like

I havn’t had any luck inside a docker container, I had luck run it on port 8000 with watch-admin if I extended admin.config.js or added the file manually.

1 Like

You might be running npm run develop --watch-admin? That will actually run the npm script called ‘develop’ and not the strapi develop command. It will not pass the option, therefore the admin watch will not run.

So, create an extra script inside the package.json so that your npm scripts reflect this:

 # inside package.json

  "scripts": {
    "develop": "strapi develop",
    "develop-admin": "strapi develop --watch-admin",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi"

Then, also expose port 8000 in the docker-compose. So, that bit should look like this:

  # inside docker-compose.yml for the strapi service

      - "1337:1337"
      - "8000:8000"
    command: npm run develop-admin

You could of course also just add the --watch-admin option to the npm develop script

I would suggest NOT run it as a docker container.
If you are doing local development, then run it locally, and have a database etc in a container much faster and less stress on a drive. It also boils down to how setup the stack.