I'm running a docker-compose container for postgresql. The postgresql database in the container is running on the standard port 5432, and I am publishing that port out to port 5444 on the host (since the host's postgresql default port is in use).
I am using the same configuration on the host and in the container (a .env file that provides config settings for cli commands and the app as a whole). Unfortunately, whichever port I choose, one system will lose access. For example, I cannot run:
[k@host]$ pgsql -p 5444 # Connects
in the host and still have work inside the container:
[k@db-container]$ pgsql -p 5444 # Errors in container
The container's postgresql-server is running on 5432:
[k@db-container]$ pgsql -p 5432 # Connects successfully in container
and the ports are published via the docker-compose.yml via: - ports: - "5444:5432"
So currently I don't know how to configure the same port everywhere simply via the docker-compose.yml! expose command exposes the port but does not allow remapping, ports forwards host<-->container, but does not remap the internal port. I have thought of remapping the postgresql default port inside the postgresql container configuration, but fully reconfiguring postgresql seems non-trivial to do via docker-compose on every docker-compose up.
How can I remap the ports inside the container so that I can use port 5444 everywhere, in the host & container?