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
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!
I can’t get it to work locally at all
I havn’t had any luck inside a docker container, I had luck run it on port
watch-admin if I extended
admin.config.js or added the file manually.
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
"develop": "strapi develop",
"develop-admin": "strapi develop --watch-admin",
"start": "strapi start",
"build": "strapi build",
Then, also expose port 8000 in the docker-compose. So, that bit should look like this:
# inside docker-compose.yml for the strapi service
command: npm run develop-admin
You could of course also just add the
--watch-admin option to the npm
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.