[Nginx] Expose specified port for Nginx in Dockerfile
When we build a custom docker image based on nginx docker image, the default lisenting port will be 8080. However, port 8080 is a quite popular, so sometimes I want to give a different port for my service. The below snippet of code is the solution. FROM nginx COPY ./public/ /usr/share/nginx/html EXPOSE 1313 CMD ["/bin/sh", "-c", "sed -i 's/listen .*/listen 1313;/g' /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"]