skip to Main Content

consider a docker .yml file like this:

version: '3.8'
services:
  postgres:
    image: postgres:13
    restart: always
    environment:
      - POSTGRES_USER=prisma_pg
      - POSTGRES_PASSWORD=benchmark
    volumes:
      - postgres:/var/lib/postgresql/data
    ports:
      - '5454:5432'
volumes:
  postgres:

after I ran these commands:

docker-compose -f ./docker-compose.yml up -d

docker-compose ps

its State is UP and the ports column showing
0.0.0.0:5432->5432/tcp
illustrates that the running port is not set to 5454->5432 as we described in the yaml file,

How can we fix it to map the port correctly?

Edit:
the file is saved in the same directory and there is no other container running before or after this one:

here is the screenshot, which probably helps:
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    I copied the docker file out of project space and it WORKED! same system, same commands! still not working in the project directory :D wondering how it's possible


  2. Try running with Compose V2 by omitting the hyphen:

    docker compose -f docker-compose.yaml
    

    Do you get the same result?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search