Changing Strapi port on docker-compose install

The default Strapi config/server.js already allows the default port to be overridden by setting up the ‘PORT’ environment variable.

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),

Setting the environment variable ‘PORT=1338’ will make Strapi start listening on port 1338 instead of 1337. But …

Somewhere deep inside the code port 1337 is hardcoded so that even if Strapi starts up on port 1338 you can’t get further than the login page because the next step is call to http://localhost:1337/admin/project-type and after that to http://localhost:1337/admin/init

This looks like a bug in Strapi itself. It means I can’t even map ports for my docker container to something other than 1337, because /admin/project-type and admin/init is always going to be requested on port 1337.