Hi,
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?
Dockerfile:
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/my_wrapper_script.sh"]
my_wrapper_script.sh - starts java and nginx process.
#!/bin/bash
# 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 $?
BUILD IMAGE
docker build -t newimage .
//Built successfully
RUN
docker run -d -p 443 newimage
Error encountered: nginx: [emerg] bind() to 0.0.0.0:443 failed (13: Permission denied)
Please provide solutions to fix this issue.
Thank you.