How to change the default port used by postfix

I am using Google Cloud Engine and the port 25, the default port used by postfix, is blocked.
I tried changing the port in but that is unfortunately not working.
I also tried using Gmail as a postfix relay but that also didn’t work.
I used docker inspect to view the postfix container and found the ports are defined there. So I assume an changes I make in .cf file regarding ports will be overridden by the docker configuration.
Is there any way I can change them?
Any help would be much appreciated.

update: I’ve managed to change the exposed port to 587 but still unable to send emails
Steps I followed:

  1. Find the docker ID, name and port of the relevant container
    docker ps --format "table {{.Names}}\t{{.ID}}\t{{.Ports}}"
  2. Note the container ID(ex: 7c79d07c0c6b) and name (ex: examplecom_postfix_1) of the postfix container corresponding to your site
  3. Stop the container
    docker stop examplecom_postfix_1
  4. Find the full container ID by listing files
    ls /var/lib/docker/containers/
  5. You’ll be presented with a list of long directory names. You have to select the one that starts with the container ID you noted down earlier and edit config.v2.json
    nano /var/lib/docker/containers/7c79d07c0c6b......./config.v2.json
  6. Change the exposed port and save the file
  7. Restart docker
    systemctl restart docker
  8. Start the docker container
    docker start examplecom_postfix_1
  9. Verify the port has indeed been changed
    docker ps --format "table {{.Names}}\t{{.ID}}\t{{.Ports}}"

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.