When trying to connect two containers on my ubuntu 16.04 host, I can not send messages from one container to the other, while the adress is available at the host.
I started one container (which provides a syslog-service by syslog-ng
) with:
docker run -d -p 127.0.0.1:515:514/udp --name syslog-ng bobrik/syslog-ng
This container is defined in: https://github.com/bobrik/docker-syslog-ng . According to https://www.balabit.com/documents/syslog-ng-ose-latest-guides/en/syslog-ng-ose-guide-admin/html/configuring-sources-network.html the udp(ip(0.0.0.0), port(514));
in the syslog-ng.conf should make it possible to accept all ip-connections.
Now I can log from the host to the container using:
logger -n 127.0.0.1 -P 515 test123
The second container was started with (one time with the --link
, once without)
docker run -it --link syslog-ng ubuntu /bin/bash
and in both cases, the logging is not available to the container, i.e.
logger -n 127.0.0.3 -P 515
returns no error message, but no message is added to the log either. (Tried it also with 127.0.0.1 and syslog-ng in case of the linked container).
So the question is: Why is logging in the container not possible?
If I start another container, both are on the same network, docker network inspect bridge
returns:
[
{
"Name": "bridge",
"Id": "6836c8a52555f30f27001daf9b111ad41a035a31783250e043c34602ea83cfe3",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Containers": {
"3acef55e018280571410b63b0cb7314ba354b67fb6523662b48ad09be8424423": {
"Name": "syslog-ng",
"EndpointID": "d6f2ad9cc9b5f6a5030e6061c4abb600ff7b0f16711f169954dd446f1351cb08",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"4f7d0101f97dca63b160e16a5e298c45f2ff51aa35085d0cdec96497a598be1a": {
"Name": "goofy_lamarr",
"EndpointID": "e357d6a99f67964bac4619d1ac984cd361a9c39137ea8d67a1ebc641e498919b",
"MacAddress": "02:42:ac:11:00:05",
"IPv4Address": "172.17.0.5/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
This is /etc/hosts
on the ubuntu container where I try to log:
cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3 syslog-ng 3acef55e0182
172.17.0.5 4f7d0101f97d
So the syslog-ng should be available with syslog-ng or 172.17.0.3.
If I understood https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/ correctly, than linking should make it possible to log directly to syslog-ng
, and without the link, I should still be able to send messages from the one container to the container which exposed a port by ip, according to https://docs.docker.com/engine/userguide/networking/.
It seems like this is the same as: Logging from one docker container to another, but there are no concrete containers provided.
Has anyone an idea why this logging isn't possible?
It works. The problem was with the port number(515), with this command:
docker run -d -p 127.0.0.1:515:514/udp --name syslog-ng bobrik/syslog-ng
you say that the internal port 514 can be reached from the host with the 127.0.0.1:515. But if you want to reach the container directly from another container, you can reach it with syslog-ng:514 or with 172.17.0.2:514:
so the correct logger will be:
logger -n syslog-ng -P 514 test123345
I hope it helps
Br,
Micek