Postkres docker could not start with the specified port

I am new to docker and I am trying to start the docker of the postgres database 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 try to run it without the -p option, it seems to be working fine, but I cannot reach it from my local pg-admin, I thought I needed to add a port link in order to achieve this.

In any case, the container always crashes after a few seconds, and when I try to start it with the start command, I get the following return:

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

What did I miss?

FYI, I run it on MacOS with the following version of docker:

 $ 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 
+6
source share
1 answer

Run the -p option to enter the container before the image name

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

Regarding the link to launch the docker run has this format

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

Parameters must be before the image name. After that, you can set an entry point or command (when they differ from the default value from the Dockerfile) and their arguments.

+8
source

Source: https://habr.com/ru/post/1013984/


All Articles