Home > Mobile >  docker postgres cant connect on non standart ports forward
docker postgres cant connect on non standart ports forward

Time:10-04

version: "3.5"
services:
  database:
    container_name: proj-database
    env_file: ../orm/.env.${PROJ_ENV}
    image: postgres
    restart: always
    expose:
      - 5433
    ports:
     - 5432:5432
     - 5433:5432
    networks:
      - proj

I can connect from other containers with 5432, but i can't from other containers connect with 5433. Whats the problem?

CodePudding user response:

Connections between containers always use the "normal" port number for the destination service. They don't consider any remappings in ports:; in fact, they don't need ports: at all. ports: are only used for connections from outside Docker into a container. Conversely, since internally each container has its own private IP address, there aren't conflicts even if you are running multiple copies of the same image.

  • Related