Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] bridge network and port mapping #283

Closed
jhoogeboom opened this issue Mar 27, 2019 · 4 comments
Closed

[Question] bridge network and port mapping #283

jhoogeboom opened this issue Mar 27, 2019 · 4 comments

Comments

@jhoogeboom
Copy link

jhoogeboom commented Mar 27, 2019

Normally docker-compose already bridges containers in the same service. It already opens all the ports to the other containers but not the host. So if you expose a container port in the Dockerfile, you can use the containername to address it. Does this methods apply to dinghy as well? That's what I thought, but perhaps I'm misunderstanding. I've setup dinghy with the default install & virtual box and made this test docker-compose:

version: "3.2"
services:
  redis:
    image: redis
    environment:
      VIRTUAL_HOST: redis.docker
      VIRTUAL_PORT: 6379
  crccheck:
    container_name: hello-world
    image: crccheck/hello-world
    environment:
      VIRTUAL_HOST: hello.docker
      VIRTUAL_PORT: 8000
  nginxdemo:
    image: nginxdemos/hello
    environment:
      VIRTUAL_HOST: nginx.docker
      VIRTUAL_PORT: 80
  ubuntu:
    container_name: ubuntu
    image: arunvelsriram/utils

Using docker-compose run ubuntu bash I can curl the Nginx.docker fine, somehow also fine on hello.docker using port 80, but not port 8000? only port 8000 is supposed to be exposed. testing Redis with redis-cli -h redis.docker is refused.

I try the same with dinghy ssh, same results.

But if I map the ports to the host (in this case the VM), or use the docker-compose 3.4 feature of network_mode: host, it works fine (although hello.docker is still also reachable from port 80, still remaining a mystery). Although now nginx won't be reachable anymore..

Is this intended behaviour or am I misunderstanding how dinghy is supposed to work?

@codekitchen
Copy link
Owner

The Dinghy proxy is an HTTP/HTTPS proxy, so it doesn't do anything to support non-HTTP protocols such as Redis. It listens on ports 80 and 443 on the Docker VM host, and reads the hostname to proxy to whatever backend port you expose, that's why your hello.docker is on port 80 not 8000.

Your redis.docker is being exposed on port 80 as well, but actually trying to connect to it won't work properly, since it's going through an HTTP proxy that doesn't understand the redis protocol.

@jhoogeboom
Copy link
Author

Thanks for the clarification, I was hoping to get the linux style container-name addressing working on Macos, but I think I misunderstood Dinghy.

@jhoogeboom
Copy link
Author

I guess the mentioned:

Sanity check!

$ docker run -it redis

is more about seeing if you can run docker commands on the connected VM rather than specifically about redis?

@codekitchen
Copy link
Owner

Well, Dinghy supports containers like redis in the same way that docker-machine does, but yeah I think that part of the README was written long before the Dinghy proxy existed.

Implementing container-name addressing would be cool, but I'm unlikely to ever do it myself, I'm not planning to add any big new features to Dinghy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants