For docker run
the order of the parameters matter, so this:
docker run 34a1650b461d -p 7200:7200
Is not the same as:
docker run -p 7200:7200 34a1650b461d
In the first case you are passing the parameters -p 7200:7200
to your ENTRYPOINT
command /bin/graphdb
; whereas in the second case, you are passing -p 7200:7200
to docker run
, which is what you wanted.
How to validate when ports are correctly forwarded?
You can validate this by running docker ps
and checking the PORTS
column:
$ docker run -d 34a1650b461d -p 7200:7200
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03abc0b390ef mytest "/bin/graphdb -p 720…" 6 seconds ago Up 5 seconds 7200/tcp elegant_wescoff
Do you see how the COMMAND
includes your -p
? That's not what you wanted. So docker run
was not interpreting that parameter at all. Also, you can see the PORTS
column, which shows the port is exposed but not forwarded.
Whereas doing it like this:
$ docker run -d -p 7200:7200 34a1650b461d
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03abc0b390ef mytest "/bin/graphdb" 6 seconds ago Up 5 seconds 0.0.0.0:7200->7200/tcp elegant_wescoff
You can see now that -p
is not being passed to COMMAND
and that the port is forwarded: 0.0.0.0:7200->7200/tcp
.