Reputation: 1141
I'm trying to run two postgres database with Docker service. I know they can't run on the same time, so I would like to change the port (not the -p 5433: 5432
)
here's my script to start the docker service:
docker service create --name account-db --network account -e POSTGRES_PASSWORD=secret_password -p 5432:5432 -d --mount type=volume,source=account,target=/var/lib/postgresql/data postgres:latest
so if I want to run one on 5432 and another on 5433, how should I achieve that? thanks for any input / suggestion
Upvotes: 1
Views: 7534
Reputation: 684
-p 5432:5432
This is the port mapping for the container. So for the first service, it should be
-p 5432:5432
And for the second service it should be
-p 5433:5432
The syntax is -p [port of the machine] : [port of the container]
Upvotes: 7