[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;'"]

[Dokku] How to set up dokku to deploy docker image

About installing the dokku, I have written another post before: How to install Dokku with Portainer. So I will assume that you have Dokku installed in your server in this post. 1. Environment Setting Dokku: version: 0.27.5. HTTP port: 80, HTTPS port: 443, SSH port: 5022 IP of remote server where the Dokku is installed: 166.23.44.25 (example) Domain: example.com Name of App that will be deployed by Dokku: blog Port of App: 3000 2. SSH Configuration Generate ssh key public file id_rsa.pub ssh-keygen -o We will name the file as dokku_rsa, then you will see two files are generated: dokku_rsa and dokku_rsa.pub. ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !