Docker for Windows, container started from console is not reachable

343 Views Asked by At

I'm starting to use docker on windows 10 home.

Docker-engine: 19.03.13

Docker-desktop: 2.4.0.0 (48506)

I've installed the latest version and everything works fine when I'm using the Windows Docker App to start the container. But when I start the container from my console (PowerShell, git-bash, cmd in admin mode) I can't reach this container.

git-bash

docker run -p 9990:9990 -d --name kc_console jboss/keycloak:latest

$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                        NAMES
e5197e5acd96        jboss/keycloak:latest   "/opt/jboss/tools/do"   5 minutes ago       Up 5 minutes        8443/tcp, 0.0.0.0:9980->8080/tcp             kc_app
9607511f2dd8        jboss/keycloak:latest   "/opt/jboss/tools/do"   6 minutes ago       Up 6 minutes        8080/tcp, 8443/tcp, 0.0.0.0:9990->9990/tcp   kc_console

kc_app container is reachable over the browser but pc_console isn't.

http://localhost:9980/auth/ works but http://localhost:9990/auth/ doesn't work

The only difference I see is the port settings.

In Docker desktop (inspect container):

pc_console (port: localhost:9990)

pc_app (port: 0.0.0.0:9980)

Anybody knows, how can I fix this? Environment problem? Missing settings?

2

There are 2 best solutions below

0
On

After trying hours and asking her I found the mistake.

I used the parameter -p wrong.

docker run -p 9990:8080 -d --name kc_console jboss/keycloak:latest

now it works as ecpected.

1
On

If you’re using Docker Toolbox then any port you publish with docker run -p will be published on the Docker Toolbox VM’s private IP address.

docker-machine ip will tell you. It is generally 192.168.99.100.

Then you can browse (192.168.99.100:8080) instead of (localhost:8080).