Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker postgres failed to start with specified port

I'm new to docker and I'm trying to run a postgres database docker with the following command :

docker run --name rva-db  -e POSTGRES_PASSWORD=rva -e POSTGRES_DB=rva-db -d postgres -p 5432:5432

If I'm trying to run it without the -p option, it seems to work fine, but I can't reach it from my local pg-admin, I thought I need to add the port link to reach it.

Anyway, the container always crash after few seconds and when i'm trying to start it with the start command I'm getting the following return :

docker start -a rva-db
FATAL:  invalid value for parameter "port": "5432:5432"

What did I miss ?

FYI, I'm running it on a MacOS with the following docker version :

$ docker version
 Client:
  Version:      1.12.1
  API version:  1.24
  Go version:   go1.7.1
  Git commit:   6f9534c
  Built:        Thu Sep  8 10:31:18 2016
  OS/Arch:      darwin/amd64

 Server:
  Version:      1.12.1
  API version:  1.24
  Go version:   go1.6.3
  Git commit:   23cf638
  Built:        Thu Aug 18 17:52:38 2016
  OS/Arch:      linux/amd64
like image 772
RVA Avatar asked Jan 11 '17 10:01

RVA


1 Answers

Run the container typing -p option before the image name

docker run --name rva-db  -e POSTGRES_PASSWORD=rva -e POSTGRES_DB=rva-db -d -p 5432:5432 postgres

As for Docker run reference docker run has this format

docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

Options must be before image name. After that you can set entrypoint or command (when theyy differ from default from Dockerfile) and their arguments.

like image 56
gile Avatar answered Oct 14 '22 02:10

gile