docker containerized zabbix server monitoring same host running the zabbix server : connection refused - docker

I m running a dockerized version of zabbix server (centos 6.0) on my host. I m also running zabbix-agent2 on this host with configuration of server with ip adress of 127.0.0.1.
When i go into zabbix frontend web interface i get these error on the detected host:
When the ip is at default value 127.0.0.1:10050:
Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Connection refused
When i change the default value to 172.17.0.1:10050 (the docker cant identify localhost of the host naturally) :
Get value from agent failed: ZBX_TCP_READ() failed: [104] Connection reset by peer
When i go to host and i ping or traceroute the host it works well.
When i go to host and i try detect operating system i get the error
Cannot execute script.
sh: sudo: command not found
What can i do to make the host work properly?
I have tried to check these posts :
Access localhost from docker container
(when i use 172.17.0.1).
I have tried to use network_mode: host but it conflicts with network being defined in the docker-compose.yml
I have tried this solution How to use the host network, and any other user-defined network together in Docker-Compose?
but it doesnt work either
The port of the docker-compose is well defined and mapped (10051:10051)

Related

connect ECONNREFUSED 127.0.0.1:8046 when connecting to host app from Docker container - Windows 10

I have a standalone app running on my machine (not in a docker container) listening to port 8046 (localhost:8046) using an ngrok tunnel (http ngrok 8046). I am trying to connect to it sending a POST from my docker container which I'm also running on my local machine using http://host.docker.internal:8046. I have tried many different approaches but nothing seems to work:
I have tried to disable my firewall to make sure that wasn't the issue.
Tried http://localhost:8046 in the container to connect to the app
Tried serving the standalone app on 0.0.0.0 with the same port 8046 and setting http://0.0.0.0:8046 in the container to connect to it, unsuccessfully
I keep having connect ECONNREFUSED 127.0.0.1:8046
my etc/hosts is configured with the IP added by docker desktop for host.docker.internal and gateway.docker.internal
I'm running out of ideas and can't figure out what I could be missing. Any ideas? Thanks in advance
Inside container localhost, 127.0.0.1, 0.0.0.0 represent the container itself. To connect to the host machine please try using its domain name or IP address in the LAN, which the host machine belongs to.

gRPC in docker container can't connect to services on host machine

I have slightly modified this example: https://github.com/grpc/grpc-web/tree/master/net/grpc/gateway/examples/echo. I am running envoy on a docker container with exposed port 8080 (running this proxy server is required because the browser can't speak directly to a backend gRPC service). I am running all the services on my localhost (the host machine of the envoy docker container). However, I cannot seem to connect envoy in the docker container to the services running on the host machine.
I compiled grpc_cli in the container and when I run grpc_cli ls 192.168.1.10:9000 (host's LAN IP address and the port the service is running on), I get
root#bdc9ac396a87:~/grpc# ./bins/opt/grpc_cli ls 192.168.1.10:9000
Received an error when querying services endpoint.
ServerReflectionInfo rpc failed. Error code: 14, message: failed to connect to all addresses, debug info: {"created":"#1569023274.866465052","description":"Failed to pick subchannel","file"
:"src/core/ext/filters/client_channel/client_channel.cc","file_line":3876,"referenced_errors":[{"created":"#1569023274.866463178","description":"failed to connect to all addresses","file":"
src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":395,"grpc_status":14}]}
I get an almost identical error when I use the IP address of the docker0 interface, which should also provide a connection to the host machine.
root#bdc9ac396a87:~/grpc# ./bins/opt/grpc_cli ls 172.17.0.1:9000
Received an error when querying services endpoint.
ServerReflectionInfo rpc failed. Error code: 14, message: failed to connect to all addresses, debug info: {"created":"#1569022455.801913949","description":"Failed to pick subchannel","file"
:"src/core/ext/filters/client_channel/client_channel.cc","file_line":3876,"referenced_errors":[{"created":"#1569022455.801910006","description":"failed to connect to all addresses","file":"
src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":395,"grpc_status":14}]}
However, running a simple http server from the host with
python -m http.server
I can run the following commands from the container just fine:
wget 172.17.0.1:8000/test.txt // works
wget 192.168.1.10:8000/test.txt // works
A client on the host (not in the container) connects and works just fine with the service, so it's not a server problem.
Does docker block certain types of traffic? I noticed in the example the server was placed on another docker container, and it worked (it also worked locally for me), but I'd prefer to have my services running on my host machine while I build and test them. Is there a setting somewhere to enable gRPC from the container to a service on the host machine?
Docker version 1.13.1, build 47e2230/1.13.1
Fedora 29

Docker container can't connect to ip host

I have deployed a netflix hystrix dashboard with turbine on a docker container, I can access to http://ip:8081/hystrix but when I try to monitor the stream of turbine it freeze and doesn't return any information, I test using curl inside the container and execute curl http://localhost:8081/turbine.stream and curl http://containername:8081/turbine.stream, with those two command works perfectly but when I use the host ip as curl http://hostip:8081/turbine.stream the curl throws Failed to connect to hostip port 8081: No route to host, I can't found a solution, can someone help me with this issue?,
Thanks in advance.
In order to access the container through Host IP you need to ensure the following:
Port mapping is allowing through the Host/Public IP itself not only localhost.
You can check this by executing docker ps on the docker host and look for the PORTS column the default should be as the following 0.0.0.0:8081->8081/tcp which means it can accept connection from any interface either public, private or localhost.
The firewall is not blocking the connection on port 8081.
By default the firewall of the host should be managed by Docker daemon itself so the port 8081 will be allowed in the firewall but you might have a different case either Docker is not managing the firewall of the host or there is an extra layer that prevents the connection

Docker: How to connect to locally available servers from within docker

I run docker on windows. I have a docker container running a python application that needs a database connection.
Installing a DB on my machine and connecting to it via "docker.for.win.localhost" in my container works fine.
Now I want to connect to a database running on a server that is available over my local network. I can't seem to connect to it from inside my docker container. I don't quite understand how I can proxy the server to my container. The error indicates that it can't establish a connection to this server:
(psycopg2.OperationalError) could not connect to server: No route to host
Is the server running on host "XX.XXX.XX.XX" and accepting
TCP/IP connections on port 5555?
I'm sure this is supposed to work somehow, right?
you can add IP of host to the container
docker run --add-host="yourhost:IPOFTHEHOST"
and yourhost will be connected to host

Can Consul be run inside a Docker container using Docker for Windows?

I am trying to make Consul work inside a Docker container, but using Docker for Windows and Linux containers. I am using the official Consul Docker image. The documentation states that the container must use --net=host for Consul's consensus and gossip protocols.
The problem is, as far as I can tell, that Docker for Windows uses a Linux VM under the hood, and the "host" of the container is not the actual host machine, but that VM. I could not find a combination of -bind, -client and -advertise parameters (IP addresses), so that:
Other Consul agents on other hosts can connect to the local agent using the host machine's IP address.
Other containerized services on the same host can query the local agent's REST interface.
Whenever I pass the host machines IP address in the LAN through -advertise, I get these errors inside the container:
2018/04/03 15:15:55 [WARN] consul: error getting server health from "linuxkit-00155d02430b": rpc error getting client: failed to get conn: dial tcp
127.0.0.1:0->10.241.2.67:8300: connect: invalid argument 2018/04/03 15:15:56 [WARN] consul: error getting server health from "linuxkit-00155d02430b": context deadline exceeded
Also, other agents on other hosts cannot connect to that agent.
Using -bind on that address fails - my guess is, since the container is inside the Linux VM, the host machine's address is not the container's host's address, and therefore cannot be bound.
I have tried various combinations of -bind, -client and -advertise, using addresses like 0.0.0.0, 127.0.0.1, 10.0.75.2 (addresss on the Docker virtual switch) and the host machine's IP, but to no avail.
I am now wondering whether this is achievable at all. I have been trying this for quite some time, and I am despairing. Any advice would be appreciated!
I have tried the whole process without using --net=host, and everything works fine. I can connect agents across hosts, and I can query the local agents REST interface from other containerized applications... Is --net=host really crucial to the functioning of Consul?

Resources