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

Document Container Networking using User-Defined Networks #172

Open
eedwardsdisco opened this issue Feb 9, 2017 · 2 comments
Open

Document Container Networking using User-Defined Networks #172

eedwardsdisco opened this issue Feb 9, 2017 · 2 comments

Comments

@eedwardsdisco
Copy link

As per Docker's pages on using --link and the new user-defined networks, using links is deprecated and may be removed in the future.

It sounds like user-defined networks have a limitation that linking for dd-agent\dogstatsd relies on:

One feature that user-defined networks do not support that you can do with --link is sharing environmental variables between containers. However, you can use other mechanisms such as volumes to share environment variables between containers in a more controlled way.

Since the alternative sounds complicated, an officially vetted list of instructions on how to properly expose dogstatsd\dd-agent to other containers without using the legacy --link option, would be useful!

@tylermann
Copy link

tylermann commented Jun 4, 2017

+1 to updating the documentation for getting statsd working without using link, as you can't use link at all for docker swarm afaik and the localhost approach also likely won't work out of the box for people using docker swarm. took me a while to figure out how to get things working (although I was also kind of new to docker swarm and overlay networks.) I'll leave this example config here that I got working but not sure if this is the best way.

  1. make sure you update your containers statsd client sending metrics to point to host 'dd-agent' or whatever you named your datadog agent container.
  2. Make sure your other containers are on the same overlay network as the docker agent
  3. Make sure your docker agent has has the NON_LOCAL_TRAFFIC env variable set (see example config below.
version: '3'
services:
    web:
        image: <your container image that sends metrics >
        networks:
            - default
        ports:
            - "80:80"
            - "443:443"
    dd-agent:
        image: datadog/docker-dd-agent:latest
        deploy:
            mode: global
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - /proc/:/host/proc/:ro
            - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
        networks:
            - default
        environment:
            API_KEY: <your datadog Key>
            SD_BACKEND: docker
            NON_LOCAL_TRAFFIC: 'True'
networks:
    default:

@bgerstle
Copy link

Thanks for the example, @tylermann! I'm curious about some aspects of this configuration:

NON_LOCAL_TRAFFIC: 'True'

Is this really necessary if the container is run globally? I assumed running it globally meant all containers could talk to their colocated datadog container.

make sure you update your containers statsd client sending metrics to point to host 'dd-agent' or whatever you named your datadog agent container.

Datadog exposes two ports by default: 8125 and 8126. I tried to search for how to pick which port to consume in a Swarm, but couldn't find anything that clearly says how to choose one of multiple ports for a particular service. In the end I tried datadog:8125 and it seemed to work 🤷🏻‍♂️.

Lastly, if I have container "DDClientA" and it's trying to send metrics to datadog:8125, does Swarm automatically route that to the container running on the same host?

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

3 participants