{"version":"https://jsonfeed.org/version/1.1","title":"Jaryl Chng's Knowledge Base","home_page_url":"https://kb.jarylchng.com","feed_url":"https://kb-jarylchng-com.pages.dev/json/","description":"<p>Welcome to the index page of my knowledge base, if you haven't done so, do visit my website at <a href=\"https://jarylchng.com\" rel=\"noopener noreferrer\" target=\"_blank\">https://jarylchng.com</a>.</p><p>I will mainly use this site to document stuff, most of which will likely be in the public domain.</p>","icon":"https://kb-static.jarylchng.com/kb-jarylchng-com/production/images/channel-c68f1f55f856ab833b4365991609dbec.png","favicon":"https://kb-static.jarylchng.com/kb-jarylchng-com/production/images/favicon-b94914f57599a477f9f72dab6bc71001.png","authors":[{"name":"Jaryl Chng"}],"language":"en-us","items":[{"id":"m3vvl9sdUjw","title":"Docker - Access Docker containers from the host via container names by synchronizing /etc/hosts","url":"https://kb.jarylchng.com/i/docker-access-docker-containers-from-the-host-vi-m3vvl9sdUjw/","content_html":"<p>When using Docker, containers within the same shared network are able to resolve one another via their hostnames. However, the same functionality is not replicated on the host of the Docker containers.</p><p><img src=\"https://kb-static.jarylchng.com/kb-jarylchng-com/production/media/rich-editor/items/m3vvl9sdUjw/image-ab670ddfb37199687af993c4359f53aa.png\"></p><p>For personal reasons, I kept Nginx load balancer on the host and did not want to forward ports of containers, but I still wanted to reverse proxy my containers.</p><h2>Solution</h2><h3><a href=\"https://hub.docker.com/r/jarylc/docker-hosts-sync\" rel=\"noopener noreferrer\" target=\"_blank\">https://hub.docker.com/r/jarylc/docker-hosts-sync</a></h3><p>Source: <a href=\"https://gitlab.com/jarylc/docker-hosts-sync\" rel=\"noopener noreferrer\" target=\"_blank\">https://gitlab.com/jarylc/docker-hosts-sync</a></p><p>A simple Golang program that I created that updates the host's /etc/hosts file whenever the Docker containers are updated, capturing the private IPs of all the containers each time. Said program is also packaged in a Docker image, so it is easily appended to your own Docker system!</p><p><img src=\"https://kb-static.jarylchng.com/kb-jarylchng-com/production/media/rich-editor/items/m3vvl9sdUjw/image-f3e9ca5601224962a12949fa7a60168b.png\"></p><p>This image automatically mirrors /etc/hosts whenever your Docker containers are changed</p><p><img src=\"https://kb-static.jarylchng.com/kb-jarylchng-com/production/media/rich-editor/items/m3vvl9sdUjw/image-1d47c873370e880f95d7503aa3d1fd9d.png\"></p><h2>Alternatives</h2><h3><a href=\"https://hub.docker.com/r/jaschweder/hosts\" rel=\"noopener noreferrer\" target=\"_blank\">jaschweder/hosts</a></h3><p>Not multi-architecture. Checks every 5 second intervals (not configurable), instead of on container creation and deletion. Big Docker image even when after compression 35mb vs 2.5mb.</p><h3><a href=\"https://hub.docker.com/r/itsziget/hosts-gen\" rel=\"noopener noreferrer\" target=\"_blank\">itsziget/hosts-gen</a></h3><p>Not multi-architecture. Based off a <a href=\"https://hub.docker.com/r/jwilder/docker-gen\" rel=\"noopener noreferrer\" target=\"_blank\">larger templating project</a> for more use-cases, 8mb vs 2.5mb.</p>","content_text":"When using Docker, containers within the same shared network are able to resolve\none another via their hostnames. However, the same functionality is not\nreplicated on the host of the Docker containers.\n\n[https://kb-static.jarylchng.com/kb-jarylchng-com/production/media/rich-editor/items/m3vvl9sdUjw/image-ab670ddfb37199687af993c4359f53aa.png]\n\nFor personal reasons, I kept Nginx load balancer on the host and did not want to\nforward ports of containers, but I still wanted to reverse proxy my containers.\n\n\nSOLUTION\n\n\nHTTPS://HUB.DOCKER.COM/R/JARYLC/DOCKER-HOSTS-SYNC\n\nSource: https://gitlab.com/jarylc/docker-hosts-sync\n\nA simple Golang program that I created that updates the host's /etc/hosts file\nwhenever the Docker containers are updated, capturing the private IPs of all the\ncontainers each time. Said program is also packaged in a Docker image, so it is\neasily appended to your own Docker system!\n\n[https://kb-static.jarylchng.com/kb-jarylchng-com/production/media/rich-editor/items/m3vvl9sdUjw/image-f3e9ca5601224962a12949fa7a60168b.png]\n\nThis image automatically mirrors /etc/hosts whenever your Docker containers are\nchanged\n\n[https://kb-static.jarylchng.com/kb-jarylchng-com/production/media/rich-editor/items/m3vvl9sdUjw/image-1d47c873370e880f95d7503aa3d1fd9d.png]\n\n\nALTERNATIVES\n\n\nJASCHWEDER/HOSTS\n\nNot multi-architecture. Checks every 5 second intervals (not configurable),\ninstead of on container creation and deletion. Big Docker image even when after\ncompression 35mb vs 2.5mb.\n\n\nITSZIGET/HOSTS-GEN\n\nNot multi-architecture. Based off a larger templating project for more\nuse-cases, 8mb vs 2.5mb.","date_published":"2024-04-14T06:04:00.000Z","_microfeed":{"web_url":"https://kb-jarylchng-com.pages.dev/i/docker-access-docker-containers-from-the-host-vi-m3vvl9sdUjw/","json_url":"https://kb-jarylchng-com.pages.dev/i/m3vvl9sdUjw/json/","rss_url":"https://kb-jarylchng-com.pages.dev/i/m3vvl9sdUjw/rss/","guid":"m3vvl9sdUjw","status":"published","itunes:episodeType":"full","date_published_short":"Sun Apr 14 2024","date_published_ms":1713074640000}}],"_microfeed":{"microfeed_version":"0.1.2","base_url":"https://kb-jarylchng-com.pages.dev","categories":[{"name":"Technology"}],"subscribe_methods":[{"name":"RSS","type":"rss","url":"https://kb-jarylchng-com.pages.dev/rss/","image":"https://kb-jarylchng-com.pages.dev/assets/brands/subscribe/rss.png","enabled":true,"editable":false,"id":"sQbXXExV58H"},{"name":"JSON","type":"json","url":"https://kb-jarylchng-com.pages.dev/json/","image":"https://kb-jarylchng-com.pages.dev/assets/brands/subscribe/json.png","enabled":true,"editable":false,"id":"nC8cjLCnOOi"}],"description_text":"Welcome to the index page of my knowledge base, if you haven't done so, do visit\nmy website at https://jarylchng.com.\n\nI will mainly use this site to document stuff, most of which will likely be in\nthe public domain.","copyright":"©2024","itunes:type":"episodic","items_sort_order":"newest_first"}}