Hi Tilal, thanks for investigating.
The option you are using is simply providing a middleware firewall rule which uses docker’s published port feature – see here for more information: Networking overview | Docker Docs
What that means is that the docker container is still opening up port 80 on its host; the docker host is still allowing port 80, and simply redirecting that port to 8101. From the docker container’s perspective, it is still using port 80.
In this situation, the docker container is not permitted to use port 80, and there’s no firewall that can be used to redirect the port. In fact, even if we add a reverse proxy to the docker image (I tried this) that does effectively the same thing you have with -p, that operation still fails because Aspose’s host attempts to open port 80 and does not have permission to do so.
What is needed is to tell the web server that Aspose runs to use a different port. For example, Heroku recommends changing the CMD for a server to be CMD gunicorn --bind 0.0.0.0:$PORT wsgi
. Translating it a bit, that command is saying "start a webserver (gunicorn) from any network the computer is attached to (0.0.0.0) and use port $PORT (instead of the default port 80).
You can see that the Aspose docker image configures the port to port 80 in line 4: Docker. Specifically, it configures an environment variable that tells ASP.NET Core to use port 80, as in “http://+:80”. But when I set that environment variable to a custom port, as you can see in my second post, the Aspose server ignores the configured port and still opens up port 80. And, again, that port 80 is still opened with the command you included – but docker is then opening up fort 8101 also, and redirecting the internal host port 80 to port 8101 on your computer.
FYI, since it’s behind a login, here’s what Heroku says about the PORT requirements:
When deploying a container app on Heroku, we require that Dockerfiles are configured to intake the randomly assigned port on a dyno - exposed as the $PORT
environmental variable.
Even though Docker allows for the usage of EXPOSE
to specify which port for an image to use, Heroku ignores those commands and goes by the port assigned to a dyno.
For example, instead of this:
PORT=8080
EXPOSE $PORT
CMD gunicorn --bind 0.0.0.0:$PORT wsgi
We ask that you do something like this:
CMD gunicorn --bind 0.0.0.0:$PORT wsgi