Home > Software engineering >  Communication from Docker-Container to outside
Communication from Docker-Container to outside

Time:10-22

I am quite new to the docker topics and I have a question of connecting container services with traditional ones.

Currently I am thinking of replacing an traditional grafana installation (directly on a linux server) with a grafana docker container.

In grafana I have to connect to different data sources like a mysql instance, a Winsows SQL Database and so on. So grafana is doing a pull of data. All these data sources reside (and will still reside) on other hosts and they are not containers.

So how can I implement that my container is able to communicate with this data sources? Is it possible by default or do I have to implement a special kind of network? I saw that there is an option called macvlan...is that the correct way?

BR Jan

CodePudding user response:

This should work out of the box, as far as I understand. At least, I'm using Grafana inside a docker container and it works perfectly.

You can test a connectivity from inside your docker container to some external resource by opening a container shell like this:

docker exec -it <container ID> /bin/bash

And then

root@a9cbebfc4564:/# curl google.com

Or

root@a9cbebfc4564:/# ping <bla-bla>

Commands above depend on a docker image environment (like OS or installed software), but this can be solved in a same was as you can do on a regular Unix env

P.S. I encountered a docker2host connection issue once, but it was due to incorrect firewall configuration on a host side.

CodePudding user response:

Since you are replacing a traditional installation, you can start with host networking. This mode give you same connectivity experience as installing on the host. A quick start is as simple as:

docker run --network host grafana/grafana

Notice there's no need to --publish or --publish-all ports as the Grafana container now share the host network.

  • Related