Ability to set Port for Postgres Docker Image?

Hi there,

Been using the circleci/postgres:9.6.2-alpine image for running postgres in my CI for our testing suite.

We’re running into an issue where we need multiple databases running locally so we tried setting different ports locally and that worked well, but we can’t get this to work as there doesn’t seem to be a way to set the Port for the circleci/postgres:9.6.2-alpine image.

Something similar to :

  - image: circleci/postgres:9.6.2-alpine
      POSTGRES_USER: root
      POSTGRES_DB: circle-test_test
      >>>POSTGRES_PORT: 5430

Would be awesome. Maybe it already exists but I couldn’t find any evidence for it in the docs.

Thank you as always!

That might exist, I don’t know. However, if not, consider a custom command to start the server. You’ll essentially have to look up the CMD in circleci/postgres:9.6.2-alpine, or indeed in the image above that.

Once you have that though, you’ll be able to amend it to inject config options in the start-up process, including the port number.

Nice yeah thank you that’s a good alternative. Will go with that if I don’t find anything else. Could probably make my own custom image with the extra config.

1 Like

This uses the same underlying config as the upstream image there is no way to override the port at this time. Making a custom image is the best approach IMHO because even if you start up postgres to run on a separate port, only 5432 is exposed in the base image so you would have a tough time reaching it.

1 Like

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