mendhak/docker-http-https-echo

Allow environment variable to specify port

Closed this issue · 8 comments

80 does not work in a container if you are not root. Thanks.

It would be great if the name of that env was PORT

Can you explain a bit, I'm not understanding the problem.

To use a different port just use -p to map from another port to 80 inside.

docker run -p 8080:80 -p 8443:443 --rm -t mendhak/http-https-echo

I want to change the port inside the container not outside. 80 requires running as root and we use this container for troubleshooting in our EKS cluster where we are not allowed to run as root. Also, we use this knative service so it would be nice if the PORT env variable inside the container was able to control what port it listens on. If it's not there 8080 should be the default as it does not require running as root. If you would like to reproduce the problem run:

docker run -p 8080:80 -p 8443:443 --rm --user 1000 -t mendhak/http-https-echo

You can see the project you forked from now does this, the default should just be 8080 though not 80.
https://github.com/solsson/docker-http-echo/blob/fdde39e26163dca48017ca70d6c9282e5cee27fd/index.js#L50

Thanks.

Aha now I see what you mean after that explanation.

I have added environment variables HTTP_PORT and HTTPS_PORT - since there are two ports being listened on. I've added this and examples to the README.md also.

I have defaulted to 80/443 so as to not break existing runners expecting 80/443.

Now you can try your command but add the environment variables:

docker run -e HTTP_PORT=8888 -e HTTPS_PORT=9999 -p 8080:8888 -p 8443:9999 --rm --user 1000 -t mendhak/http-https-echo

I've pushed to docker hub

The SIGINT has been handled yesterday as well, both the SIGINT handling and environment should now be in docker hub, you'll need to pull latest

Thank you

Thanks for raising it @AceHack