Host web browser cannot access Docker container


Gabor Szabo

I executed a service in a docker container and exposed the container port 8080to the host port 6000. Order:

docker run \
    -d \
    --rm \
    --name keycloak \
    -p 6000:8080 \
    -e KEYCLOAK_USER=admin \
    -e KEYCLOAK_PASSWORD=admin \
    quay.io/keycloak/keycloak \
    -b 0.0.0.0 \
    -Djboss.http.port=8080

the result ofdocker ps -a

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                              NAMES
71c6a8ea6529        quay.io/keycloak/keycloak   "/opt/jboss/tools/do…"   About an hour ago   Up About an hour    8443/tcp, 0.0.0.0:6000->8080/tcp   keycloak

the result ofdocker inspect keycloak

"Ports": {
                "8080/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "6000"
                    }
                ],
                "8443/tcp": null
            },

the result ofps aux | grep docker

root        1481  0.0  0.5 1600328 83560 ?       Ssl  18:17   0:02 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root        2995  0.0  0.0 549300  4448 ?        Sl   18:18   0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6000 -container-ip 172.17.0.2 -container-port 8080
root        3009  0.0  0.0 109104  5140 ?        Sl   18:18   0:00 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/71c6a8ea6529bdcb1a04d5fa73b5ca0053a4d012905d592b6b342f1b0e8c9047 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc

When I use curlit I can reach the service inside the container.curl -v http://localhost:6000/auth

*   Trying 127.0.0.1:6000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 6000 (#0)
> GET /auth/ HTTP/1.1
> Host: localhost:6000
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: no-cache, must-revalidate, no-transform, no-store
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Referrer-Policy: no-referrer
< Content-Security-Policy: frame-src 'self'; frame-ancestors 'self'; object-src 'none';
< Date: Sun, 30 Aug 2020 17:44:03 GMT
< Connection: keep-alive
< X-Robots-Tag: none
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< X-Content-Type-Options: nosniff
< Content-Type: text/html;charset=utf-8
< Content-Length: 4070

When I try the same in google-chrome web browser, I get the error:

This site can’t be reached
The webpage at http://localhost:6000/auth/ might be temporarily down or it may have moved permanently to a new web address.
ERR_UNSAFE_PORT

Why can't Google Chrome browser use localhostand exposed port to access docker service ?

Conrad Porter

X11 uses port 6000 by default, so Chrome considers port 6000 unsafe (see here for a list of other unsafe, blocking ports, and an explanation here ).

You need to change it to one of the secure ports, or start Chrome as follows:

chrome --explicitly-allowed-ports=6000

Related


Host web browser cannot access Docker container

Gabor Szabo I executed a service in a docker container and exposed the container port 8080to the host port 6000. Order: docker run \ -d \ --rm \ --name keycloak \ -p 6000:8080 \ -e KEYCLOAK_USER=admin \ -e KEYCLOAK_PASSWORD=admin \

Host web browser cannot access Docker container

Gabor Szabo I executed a service in a docker container and exposed the container port 8080to the host port 6000. Order: docker run \ -d \ --rm \ --name keycloak \ -p 6000:8080 \ -e KEYCLOAK_USER=admin \ -e KEYCLOAK_PASSWORD=admin \

Host web browser cannot access Docker container

Gabor Szabo I executed a service in a docker container and exposed the container port 8080to the host port 6000. Order: docker run \ -d \ --rm \ --name keycloak \ -p 6000:8080 \ -e KEYCLOAK_USER=admin \ -e KEYCLOAK_PASSWORD=admin \

Host web browser cannot access Docker container

Gabor Szabo I executed a service in a docker container and exposed the container port 8080to the host port 6000. Order: docker run \ -d \ --rm \ --name keycloak \ -p 6000:8080 \ -e KEYCLOAK_USER=admin \ -e KEYCLOAK_PASSWORD=admin \

Access apache2 residing in Docker container from host web browser

h_a86 I've been creating a web server as a Docker container and trying to access it outside the container. But I can't. What am I doing. -Pull the ubuntu image: docker pull ubuntu:14.04 - start the container: docker -t -i -p 49200:2375 [image-id] After insta

Docker container can access DNS but cannot resolve host

Nelson: I have an interesting problem running a docker container: suddenly, I can't resolve DNS from inside the container. Here is a summary: Nothing was fixed; apt-get, pip, one-time ping containers, etc. Run the docker run -it --dns=8.8.8.8 ubuntu ping www.g

Docker container can access DNS but cannot resolve host

Nelson: I have an interesting problem running a docker container: suddenly, I can't resolve DNS from inside the container. Here is a summary: Nothing was fixed; apt-get, pip, one-time ping containers, etc. Run the docker run -it --dns=8.8.8.8 ubuntu ping www.g

Docker container can access DNS but cannot resolve host

Nelson I have an interesting problem running a docker container: suddenly, I can't resolve DNS from inside the container. Here is a summary: Nothing was fixed; apt-get, pip, one-time ping containers, etc. Run docker run -it --dns=8.8.8.8 ubuntu ping www.google

Docker container can access DNS but cannot resolve host

Nelson: I have an interesting problem running a docker container: suddenly, I can't resolve DNS from inside the container. Here is a summary: Nothing was fixed; apt-get, pip, one-time ping containers, etc. Run the docker run -it --dns=8.8.8.8 ubuntu ping www.g

How to access Docker container's web server from host

entropy: I am running under boot2docker 1.3.1. I have a Docker container running a web server via uwsgi --http :8080. If I connect to the container, I can browse the website using lynx http://127.0.0.1:8080so I know the server is running. I run the container w

How to access Docker container's web server from host

entropy I am running under boot2docker 1.3.1. I have a Docker container running a web server via uwsgi --http :8080. If I connect to the container, I can browse the website with lynx http://127.0.0.1:8080so I know the server is running. I run the container wit

How to access Docker container's web server from host

entropy: I am running under boot2docker 1.3.1. I have a Docker container running a web server via uwsgi --http :8080. If I connect to the container, I can browse the website using lynx http://127.0.0.1:8080so I know the server is running. I run the container w

How to access Docker container's web server from host

entropy: I am running under boot2docker 1.3.1. I have a Docker container running a web server via uwsgi --http :8080. If I connect to the container, I can browse the website using lynx http://127.0.0.1:8080so I know the server is running. I run the container w

Docker container cannot write on host

jaw First, I couldn't find an answer on SO ( this is a recent post ). I have EC2 running Ubuntu. First, I installed Jenkins, then installed Docker. Not "DonD". My project has a Jenkinsfile and I am running some docker commands. One should use a docker containe