Unable to access web server in Docker swarm from host


Mount

I started using Docker on macOS and got stuck trying to complete part 4 of the Getting Started Guide . I created two additional virtual machines ( and ), set up as cluster manager and worker respectively. Then, a stack of 5 Flask web servers was deployed using the steps in Part 3 of this tutorial . The processes seem to start fine and are distributed between the two machines, but I can't access the processes from the host using a browser.myvm1myvm2myvm1myvm2docker-compose.yml

How should I configure port forwarding/networking to be able to access the web server in the cluster from the virtual machine host running the docker container?

Below is a list of commands I have run, some with resulting output.

$ docker-machine create --driver virtualbox myvm1
$ docker-machine create --driver virtualbox myvm2

$ docker-machine ls
NAME    ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
myvm1   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.0
myvm2   -        virtualbox   Running   tcp://192.168.99.101:2376           v18.09.0

$ docker-machine ssh myvm1 "docker swarm init --advertise-addr 192.168.99.100"
$ docker-machine ssh myvm2 "docker swarm join --token <my-token-inserted-here> 192.168.99.100:2377"

$ eval $(docker-machine env myvm1)
$ docker-machine ls
NAME    ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
myvm1   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.0
myvm2   -        virtualbox   Running   tcp://192.168.99.101:2376           v18.09.0

$ docker stack deploy -c docker-compose.yml getstartedlab

$ docker stack ps getstartedlab
ID                  NAME                  IMAGE                            NODE                DESIRED STATE       CURRENT STATE              ERROR               PORTS
it9asz4zpdmi        getstartedlab_web.1   mochr/test_repo:friendly_hello   myvm2               Running             Preparing 18 seconds ago
645gvtnde7zz        getstartedlab_web.2   mochr/test_repo:friendly_hello   myvm1               Running             Preparing 18 seconds ago
fpq6cvcf3e0e        getstartedlab_web.3   mochr/test_repo:friendly_hello   myvm2               Running             Preparing 18 seconds ago
plkpximnpobf        getstartedlab_web.4   mochr/test_repo:friendly_hello   myvm1               Running             Preparing 18 seconds ago
gr2p8a0asatb        getstartedlab_web.5   mochr/test_repo:friendly_hello   myvm2               Running             Preparing 18 seconds ago

of docker-compose.yml:

version: "3"
services:
  web:
    image: mochr/test_repo:friendly_hello
    deploy:
      replicas: 5
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
      restart_policy:
        condition: on-failure
    ports:
      - "4000:80"
    networks:
      - webnet
networks:
  webnet:
Neighbor

It appears this is a known issue with the current version of boot2docker : https://github.com/docker/machine/issues/4608

The workaround is to use a cluster based on machines that don't require boot2docker (e.g. AWS, DigitalOcean, etc.), wait until a new version of boot2docker is released, or use an earlier version of boot2docker as described in that link. To use an earlier version:

export VIRTUALBOX_BOOT2DOCKER_URL=https://github.com/boot2docker/boot2docker/releases/download/v18.06.1-ce/boot2docker.iso

Before creating a virtual machine with docker-machine. (delete the existing virtual machine first, then use that export, then delete docker-machine create myvm1)

You should then be able to start the stack and access the container at 192.168.99.100:4000 or 192.168.99.101:4000 (or whatever IP address is revealed by docker-machine ls)

Related


Unable to access web server in Docker swarm from host

Mount I started using Docker on macOS and got stuck trying to complete part 4 of the Getting Started Guide . I created two additional virtual machines ( and ), set up as cluster manager and worker respectively. Then, a stack of 5 Flask web servers was deployed

Unable to access server inside docker container from host

prolink007: I am hosting the mysqlserver and HTTP server in Docker . I can't access the http server from the host. My host is a Mac.go I try to use localhost:8080and ipofserver:8080. I got it ipfrom there docker inspect. I can connect to the server from the my

Unable to access server inside docker container from host

prolink007: I am hosting the mysqlserver and HTTP server in Docker . I can't access the http server from the host. My host is a Mac.go I try to use localhost:8080and ipofserver:8080. I got it ipfrom there docker inspect. I can connect to the server from the my

Unable to access server inside docker container from host

prolink007: I am hosting the mysqlserver and HTTP server in Docker . I can't access the http server from the host. My host is a Mac.go I try to use localhost:8080and ipofserver:8080. I got it ipfrom there docker inspect. I can connect to the server from the my

Unable to access VirtualBox web server on port 9000 from host OS

grssnbchr I have an Ubuntu 12.04 guest VB on a W7 host. On the guest, I am running a web server on port 9000 and the web server is accessible from the guest from above 127.0.0.1:9000. In VirtualBox, I have two network adapters enabled for the guest. I didn't c

Unable to access VirtualBox web server on port 9000 from host OS

grssnbchr I have an Ubuntu 12.04 guest VB on a W7 host. On the guest, I am running a web server on port 9000 and the web server is accessible from the guest from above 127.0.0.1:9000. In VirtualBox, I have two network adapters enabled for the guest. I didn't c

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

Unable to access docker container from host (osx)

Lucas Yannon I'm using docker-compose and trying to run it on my dev machine, I found that when I try to connect to my api using localhost it sends an empty response MacBook-Air:api lucas$ curl localhost:3001 curl: (52) Empty reply from server When I stop doc

Unable to access Docker container from host

Nick Vargas I'm trying to get a Tomcat application server running on a Docker container. The server is running, but I can't access it from the host. The command I am running to start the container is docker run -d -p 9080:9080 example/server I can type on th

Unable to access Docker container from host

Nick Vargas I am trying to get a Tomcat application server running on a Docker container. The server is running, but I can't access it from the host. The command I am running to start the container is docker run -d -p 9080:9080 example/server I can type on t

Unable to access Docker container from host

Nick Vargas I am trying to get a Tomcat application server running on a Docker container. The server is running, but I can't access it from the host. The command I am running to start the container is docker run -d -p 9080:9080 example/server I can type on t

Unable to access server running in container from host

Alexander Mills I have a simple Dockerfile FROM golang:latest RUN mkdir -p /app WORKDIR /app COPY . . ENV GOPATH /app RUN go install huru EXPOSE 3000 ENTRYPOINT /app/bin/huru I build like this: docker build -t huru . and run like this: docker run -it -p 3000

Unable to access server on Virtual Box from host?

Banuradi I'm running Ubuntu 18.04.1 in Virtual Box for MacOS. I'm setting up a server localhostin Ubuntu with Python Flask running on Python Flask , http://127.0.0.1:5000/trying to access that localhost from a Mac, but can't. I used a bridge type connection fo

Unable to access server on Virtual Box from host?

Banuradi I'm running Ubuntu 18.04.1 in Virtual Box for MacOS. I'm setting up a server localhostin Ubuntu with Python Flask running on Python Flask , http://127.0.0.1:5000/trying to access that localhost from a Mac, but can't. I used a bridge type connection fo

Unable to access server running in container from host

Alexander Mills I have a simple Dockerfile FROM golang:latest RUN mkdir -p /app WORKDIR /app COPY . . ENV GOPATH /app RUN go install huru EXPOSE 3000 ENTRYPOINT /app/bin/huru I build like this: docker build -t huru . and run like this: docker run -it -p 3000

Access Jetty server inside Docker from host

reject I've been trying to deploy a Jetty server using docker-compose but can't seem to make the application's port available from the host machine. Here is my compose.yml: version: '3.3' networks: app-network: services: db: image: postgres:alpine

Access Jetty server inside Docker from host

reject I've been trying to deploy a Jetty server using docker-compose but can't seem to make the application's port available from the host machine. Here is my compose.yml: version: '3.3' networks: app-network: services: db: image: postgres:alpine

Access Jetty server inside Docker from host

reject I've been trying to deploy a Jetty server using docker-compose but can't seem to make the application's port available from the host machine. Here is my compose.yml: version: '3.3' networks: app-network: services: db: image: postgres:alpine

Access a server running on docker from the host

Dangira I have a rest api server running on a docker container. The server runs on port 8000 of the docker container, and port 8081 of the host is bound to port 8000 of the container. By connecting to the container and doing curl localhost:8000 I can see that

Access Jetty server inside Docker from host

Refuse I've been trying to deploy a Jetty server using docker-compose but can't seem to make the application's port available from the host machine. Here is my compose.yml: version: '3.3' networks: app-network: services: db: image: postgres:alpine

Unable to access web server created by Docker

Teoman Shipahi For a Windows 10 machine, I am following the docker documentation to create a local web server. I run the following command; docker run -d -p 8086:8086 --name webserver nginx and docker inspect webserver This gives me output like; "Networks":

Unable to access web server created by Docker

Teoman Shipahi For a Windows 10 machine, I am following the docker documentation to create a local web server. I run the following command; docker run -d -p 8086:8086 --name webserver nginx and docker inspect webserver This gives me output like; "Networks":