I have 2 containers that need to talk to each other. the first container simulates sendmail daemon to mock out sending email. The second is localstack mocking out sending an email alert due do a cloud watch alarm. Apparently I am the only person in the whole world having this problem. The localstack people are at a complete loss on why I cannot have their pro-examples talk to SMTP4DEV.
OS = latest Mac OS Monterey 12.6
container 1 (smtp4dev to simulate sending email):
docker run --rm -it -p 3000:80 -p 2525:25 rnwood/smtp4dev
I have a python program that creates a mail message and when it sends. a mail message shows up in the smtp4dev container.
container 2:
export SMTP_HOST=host.docker.internal:2525
DEBUG=1 DNS_ADDRESS=127.0.0.1 LOCALSTACK_API_KEY=####### SMTP_HOST=host.docker.internal:2525 localstack start
when I run the code at https://github.com/localstack/localstack-pro-samples/tree/master/cloudwatch-metrics-aws. The log in the container is showing the it is trying to send a message to the SMTP4DEV container but fails.
both containers are in the bridge network. I would think that being in the same network they should be able to talk to each other
docker network inspect bridge
[
{
"Name": "bridge",
"Id": "150e446de01292139f0ff57b46cfbc1ab5b091ab589911cb88f3ee3abda983be",
"Created": "2022-10-11T18:37:05.724386042Z",
"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,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"5be878e9738953a0e7047da51bc855c80c939d6c21bc5fbbedf61d4e2ddfb6e2": {
"Name": "localstack_main",
"EndpointID": "455353f471e1c9f80fcba66216c5c5face8a07bab9b6b66f9da39fecc221d5b4",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"f16d5edf8b42286ac3484e307761c0bd63a49532f5f019321587c8a9588eb942": {
"Name": "goofy_haibt",
"EndpointID": "8ee0ab91dc3a3c308063b0da8e806c4b0a26a8297e6cc4549ba6dfd12d51a1fa",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/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": {}
}
]
I have a workaround. the option LAMBDA_DOCKER_NETWORK can be used to set the network from localstack.
DEBUG=1 DNS_ADDRESS=127.0.0.1 LOCALSTACK_API_KEY=dddddd SMTP_HOST=host.docker.internal:2525 LAMBDA_DOCKER_NETWORK=host localstack start
the real solution would be to use the "DOCKER_FLAGS" environment variable will the value of "--add-host=host.docker.internal:host-gateway". I am have asked LocalStack how I should tell use the host.docker.internal?
Related
Here I am having two proxy and my_ngnix containers running inside docker
I have two containers inside one network "bridge" as below
C:\> docker network inspect bridge
[
{
"Name": "bridge",
"Id": "82ffe522177d113af71d150c96b5e43df8946b9f17f901152cc2b4b96caf313a",
"Created": "2022-12-25T14:38:40.7492988Z",
"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,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"008e6142e13e91624e89b26ba697bff60765965a09daedafa6db766f30b6beb9": {
"Name": "proxy",
"EndpointID": "ed0536b6b97d9ad00b8deeb8dc5ad6f91e9809af3fc4032dfca4abd02760cc71",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"e215ead97a7e6580d3f6fec0f25790771af9f878b4194d61fa041b218a2117bf": {
"Name": "my_ngnix",
"EndpointID": "f0e7a6e824c18587a1cb32de89dbc8a1ec2fa62dcc7fe38516d294d7fdb19606",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/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": {}
}
]
the moment I hit the command
C:\> docker container exec -it my_ngnix ping proxy
it shows me error : ping: proxy: Temporary failure in name resolution
can anyone help me here ---
I have installed all required update on container so I can use ping command
why container is not able to ping each other using container name ---same command work with ip address
I tried to use the same command using IP address as below
docker container exec -it my_ngnix ping 172.17.0.3
it works , however it wont work with the container name.
I have a python 3.6 app running inside a docker container (linux python3.6 base image), and this app needs to access another container with a redis instance on it. I have both containers running on the default bridge network, and I have configured the first container to point to the second using the second container's IPv4Address:
CELERY_RESULT_BACKEND = redis://172.17.0.3:6379/0
According to the tutorials on docker, this is all you need to connect one container to another when they're running on the same host machine(with no firewalls etc). However, I keep getting a [Errno 111] Connection refused when I try to connect to the redis container. I have checked that the ICC is enabled, and my default bridge network looks like this:
[
{
"Name": "bridge",
"Id": "fda5906e0a6009a5a7dd8839f4d85cdc8de15db34481b7ef15ce66f4343b2f63",
"Created": "2021-03-24T07:54:17.8315909Z",
"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,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"38beb0863d86dab0f014ef9f1ad85f02efa7fb96520455df6f6ea6b5519f60cc": {
"Name": "local_redis",
"EndpointID": "74f510467dba138f10e1662830060a05ee192c368b32844af73eb4e865fc7182",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"f314393b25019c8c3084b8cf8465284d5a45c2f48c9aa5c411343e6a5f833c62": {
"Name": "rabbitmq",
"EndpointID": "a4886c398708d5279a8bf0de9dbd8eadd10dd320120243a2ca8c26e0e0c20e16",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/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": {}
}
]
Any help would be much appreciated.
I have 2 docker containers running on my windows 10 machine. I have been able to interact with them by binding container ports to host ports, but now I want to dockerize another application that I have been using to interact with these containers. Up until now I have been configuring the urls using localhost, but after moving the third application to a container that will no longer be an option, so I did some research and decided to use the default bridge network. I checked that all 3 containers were in the network:
[
{
"Name": "bridge",
"Id": "c570148be95b87b5bc768de573e85c25fa4584df2c5df5c63b2d317decabe651",
"Created": "2021-03-22T07:49:32.2206325Z",
"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,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"38beb0863d86dab0f014ef9f1ad85f02efa7fb96520455df6f6ea6b5519f60cc": {
"Name": "my_redis",
"EndpointID": "58a6cfab6f233ac39c9b043c660124fd9cb98970f99f154ad8b3774a3356e71b",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"70fe60faa0dc3b853edcf2005e16d6219015eafa1c65d48aebd57256ff329f2b": {
"Name": "rabbitmq",
"EndpointID": "ed4ac901659785eebfd58de4056efd51addd19eda8c184a38632f1486c178e53",
"MacAddress": "02:42:ac:11:00:04",
"IPv4Address": "172.17.0.4/16",
"IPv6Address": ""
},
"b34359519bbf0253af3eba8e800a1bcabeb3cfe6e5cc5007679c6f632f1d4820": {
"Name": "app",
"EndpointID": "3363141459cc7eebeca1651b047ed3af81c4af37c3706dfa74e5eadb6f95f302",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/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": {}
}
]
From what I can see, icc is enabled and all 3 containers are on the network. I used the IPv4Address in the configuration in app: STA_REDIS_HOST = 172.17.0.3 (with and without the /16 at the end, because I'm not sure what it means), and it seems as if the ip is being resolved to something else, because I get the following error:
Error 111 connecting to 127.0.0.1:6379. Connection refused.
I don't know where 127.0.0.1 but it looks like the private ip of the host machine.
Where am I going wrong here?
I didn't get how you are trying to connecting one container to other...
docker_bridge_network demonstrates pinging one container to others by using bridge network
I have a HTTP server running in a Docker container. I need to be able to log requests in this container, including their source IPs, but all packets over IPv6 appear to come from the IPv4 address of the Docker network's gateway.
This originally made sense, as the Docker network did not have IPv6 enabled, so I assume Docker automatically translated to IPv4, but having enabled IPv6 on the network, I see no change. This likely means that I configured something wrong, but I can't seem to figure it out.
My network configuration is as follows (created by Portainer):
{
"Name": "aais",
"Id": "2823152591e7f437244623ba46f66aff7eacba2e92942fbcf681f2f145fff783",
"Created": "2021-01-11T21:52:27.632515156Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": true,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
},
{
"Subnet": "fd00:1255:2111::/48",
"Gateway": "fd00:1255:2111::1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"6931497b76e36992c1ec9d2c6fadf4ed8492f8d7dd1bb4b01b2796f0e5204969": {
"Name": "caddy",
"EndpointID": "be6bb2824a3f7c5ddb73ec45c5b37d7c439a461a65d00759e7eab68edb49548c",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": "fd00:1255:2111::2/48"
}
},
"Options": {
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "false",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
I ended up using a semi-temporary solution, namely:
https://github.com/robbertkl/docker-ipv6nat
which makes configuring IPv6 in docker much simpler. However, a similar feature is expected to come do Docker soon anyway, as tracked by:
https://github.com/robbertkl/docker-ipv6nat/issues/65
https://github.com/moby/libnetwork/pull/2572
So this should be the preferred solution for any future users.
I am not able to connect to docker container when there is network/ip change from office to home. But the same works with localhost or 127.0.0.1
I am connecting to VPN to connect to database.
root#1c970ed5cd64:/etc# curl
http://localhost:8090/admin/health_check/all
{“health”:“passed”}root#1c970ed5cd64:/etc# curl
http://192.168.0.103:8090/admin/health_check/all curl: (7) Failed to
connect to 192.168.0.103 port 8090: Connection refused
When i install docker again everything works fine.
I have created docker-machine with external virtual switch pointing to wifi and ran the container with the host ip.
The same working on diffferent machine. Below i have not seen DOCKER_HOST ip when i do inspect the network
PS C:\Users\KH1046> docker network inspect -v 6fad6cc07d43 [
{
"Name": "bridge",
"Id": "6fad6cc07d43f576ca4921559346a4919ea6ffd8172726adccb31b4ffaa23acd",
"Created": "2017-08-12T18:07:33.2239814Z",
"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,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"b81f7e258650a150c72ab255c35d321a9a01aea090c6e03ec38de6c373ebfe46": {
"Name": "konymobilefabric_tomcat",
"EndpointID": "ae18e2a9874ab56967d06450ea7b26c7f47c408ff173c1610ac7bd0b322e24d3",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/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": {}
} ]
Thanks,
Kusuma