{"id":125,"date":"2023-01-08T22:31:37","date_gmt":"2023-01-08T21:31:37","guid":{"rendered":"https:\/\/trashdump.net\/?p=125"},"modified":"2024-11-02T10:12:14","modified_gmt":"2024-11-02T09:12:14","slug":"inter-container-communication","status":"publish","type":"post","link":"https:\/\/trashdump.net\/?p=125","title":{"rendered":"Inter Container Communication"},"content":{"rendered":"<h2 id='problem'  id=\"boomdevs_1\" >Problem<\/h2>\n<p>Running services in container enrironments often leads to the need enabling access from one conteiner to another. This is quiet easy, if we are runnung all containers in the same docker net. If the containers running in different networks, we have to access the other container by connecting the exposed port on the host.<br \/>\nSince we are running in a container <em>localhost<\/em>  is refering to the container itself. In the first it seems simple to connect to IP or hostname of the host in its LAN, but this is not very flexible. If the host gets another IP oder the container moves to another system, the config allways has to be adopted.<\/p>\n<h2 id='possible-solution'  id=\"boomdevs_2\" >Possible Solution<\/h2>\n<p>While instancing the container, we create an entry in the docker internal address solution to refere to the host.<\/p>\n<pre><code class=\"language-bash-- line-numbers\">docker run -d \\\n  --restart: always \\\n  --add-host host.docker.internal:host-gateway \\\n  alpine:latest\n<\/code><\/pre>\n<p>Or within<br \/>\n&#8220;`docker-compose.yaml&#8220;` &#8230;<\/p>\n<pre><code class=\"language-yaml-- line-numbers\">...\nservices:\n  my_host:\n    restart: always\n    image: alpine:latest\n    extra_hosts:\n      - host.docker.internal:host-gateway\n...\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Problem Running services in container enrironments often leads to the need enabling access from one conteiner to another. This is quiet easy, if we are runnung all containers in the same docker net. If the containers running in different networks, we have to access the other container by connecting the exposed port on the host. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-virtualisierung"],"_links":{"self":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125"}],"version-history":[{"count":3,"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":148,"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions\/148"}],"wp:attachment":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}