Solution required for nginx: [emerg] bind() to failed (13: Permission denied) encountered during docker run


I am currently exploring the usage of the Nginx Docker image within our project. I have to run the container as non-root user binding to the ports 80/443 in secure way. Am facing permission denied issue due to non-root user. How to bind to port 80/443 as non-root user?


FROM alpine:3.15.4 (base image)
add nginx, openjdk11-jre-headless and bash

//add non-root user
RUN addgroup -g 3080 -S xyz && adduser -u 3080 -S -G xyz xyz
USER xyz

//copy nginx config files
//copy backend java jar files
CMD ["/bin/bash", "/opt/"] - starts java and nginx process.


# Start the first process
java -jar /opt/backend/springdocker-0.0.1-image.jar &

# Start the second process
nginx -g "daemon off;" &

wait -n
exit $?

docker build -t newimage .
//Built successfully

docker run -d -p 443 newimage

Error encountered: nginx: [emerg] bind() to failed (13: Permission denied)
Please provide solutions to fix this issue.

Thank you.

You made the exact post here: Solution Required for nginx: [emerg] bind() to failed (13: Permission denied).

I am closing this topic now.