{"id":1141,"date":"2022-05-25T11:16:41","date_gmt":"2022-05-25T11:16:41","guid":{"rendered":"https:\/\/mklasen.com\/?p=1141"},"modified":"2022-05-25T11:34:17","modified_gmt":"2022-05-25T11:34:17","slug":"set-a-static-ip-for-docker-compose-containers","status":"publish","type":"post","link":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/","title":{"rendered":"Set a static IP for docker-compose containers"},"content":{"rendered":"\n

I have an amazing setup on my office. It’s an extended version of Halcyon<\/a>, with a VPN and DNS container. But there is <\/s> was one thing that was going wrong..<\/p>\n\n\n\n

Each time I restarted the server (or that time when a power outage occurred), the container’s internal IP addresses would change. The VPN container, and the configuration files generated by the container are set to use the DNS container with it’s internal IP address.<\/p>\n\n\n\n

That meant that I had to setup VPN access whenever the server restarted. This is a huge problem, especially when you’re far away from home.<\/p>\n\n\n\n

The solution<\/h2>\n\n\n\n

The solution is actually much easier than I expected, the only thing I had to do was setting the ipv4 address in my docker-compose.yml file, as below:<\/p>\n\n\n\n

    networks:\n      default:\n        ipv4_address: 172.24.0.79<\/code><\/pre>\n\n\n\n

All my containers were already connected to shared network, this is accomplished by adding these lines of code your docker-compose.yml file:<\/p>\n\n\n\n

networks:\n  default:\n    external:\n      name: your-network-name<\/code><\/pre>\n\n\n\n

The network is created by:<\/p>\n\n\n\n

docker network create your-network-name<\/code><\/pre>\n\n\n\n

Happy developing!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

I have an amazing setup on my office. It’s an extended version of Halcyon, with a VPN and DNS container. But there is was one thing that was going wrong.. Each time I restarted the server (or that time when a power outage occurred), the container’s internal IP addresses would change. The VPN container, and […]<\/p>\n","protected":false},"author":1,"featured_media":1143,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1,5],"tags":[],"acf":[],"yoast_head":"\nSet a static IP for docker-compose containers - Marinus Klasen<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Set a static IP for docker-compose containers - Marinus Klasen\" \/>\n<meta property=\"og:description\" content=\"I have an amazing setup on my office. It’s an extended version of Halcyon, with a VPN and DNS container. But there is was one thing that was going wrong.. Each time I restarted the server (or that time when a power outage occurred), the container’s internal IP addresses would change. The VPN container, and […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\" \/>\n<meta property=\"og:site_name\" content=\"Marinus Klasen\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-25T11:16:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-25T11:34:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1095\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Marinus Klasen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/marinusklasen\" \/>\n<meta name=\"twitter:site\" content=\"@marinusklasen\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marinus Klasen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuut\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\"},\"author\":{\"name\":\"Marinus Klasen\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"headline\":\"Set a static IP for docker-compose containers\",\"datePublished\":\"2022-05-25T11:16:41+00:00\",\"dateModified\":\"2022-05-25T11:34:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\"},\"wordCount\":169,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"image\":{\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png\",\"articleSection\":[\"General\",\"Technical\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\",\"url\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\",\"name\":\"Set a static IP for docker-compose containers - Marinus Klasen\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png\",\"datePublished\":\"2022-05-25T11:16:41+00:00\",\"dateModified\":\"2022-05-25T11:34:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png\",\"width\":1095,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mklasen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\/\/mklasen.com\/general\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Set a static IP for docker-compose containers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mklasen.com\/#website\",\"url\":\"https:\/\/mklasen.com\/\",\"name\":\"Marinus Klasen\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mklasen.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"nl-NL\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\",\"name\":\"Marinus Klasen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"width\":1500,\"height\":1000,\"caption\":\"Marinus Klasen\"},\"logo\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\"},\"description\":\"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter\",\"sameAs\":[\"http:\/\/facebook.com\/marinus.klasen\",\"https:\/\/nl.linkedin.com\/in\/marinusklasen\",\"https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Set a static IP for docker-compose containers - Marinus Klasen","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/","og_locale":"nl_NL","og_type":"article","og_title":"Set a static IP for docker-compose containers - Marinus Klasen","og_description":"I have an amazing setup on my office. It’s an extended version of Halcyon, with a VPN and DNS container. But there is was one thing that was going wrong.. Each time I restarted the server (or that time when a power outage occurred), the container’s internal IP addresses would change. The VPN container, and […]","og_url":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/","og_site_name":"Marinus Klasen","article_publisher":"http:\/\/facebook.com\/marinus.klasen","article_author":"http:\/\/facebook.com\/marinus.klasen","article_published_time":"2022-05-25T11:16:41+00:00","article_modified_time":"2022-05-25T11:34:17+00:00","og_image":[{"width":1095,"height":400,"url":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png","type":"image\/png"}],"author":"Marinus Klasen","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/marinusklasen","twitter_site":"@marinusklasen","twitter_misc":{"Written by":"Marinus Klasen","Est. reading time":"1 minuut"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#article","isPartOf":{"@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/"},"author":{"name":"Marinus Klasen","@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"headline":"Set a static IP for docker-compose containers","datePublished":"2022-05-25T11:16:41+00:00","dateModified":"2022-05-25T11:34:17+00:00","mainEntityOfPage":{"@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/"},"wordCount":169,"commentCount":0,"publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"image":{"@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage"},"thumbnailUrl":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png","articleSection":["General","Technical"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/","url":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/","name":"Set a static IP for docker-compose containers - Marinus Klasen","isPartOf":{"@id":"https:\/\/mklasen.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage"},"image":{"@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage"},"thumbnailUrl":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png","datePublished":"2022-05-25T11:16:41+00:00","dateModified":"2022-05-25T11:34:17+00:00","breadcrumb":{"@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#primaryimage","url":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png","width":1095,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/mklasen.com\/set-a-static-ip-for-docker-compose-containers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mklasen.com\/"},{"@type":"ListItem","position":2,"name":"General","item":"https:\/\/mklasen.com\/general\/"},{"@type":"ListItem","position":3,"name":"Set a static IP for docker-compose containers"}]},{"@type":"WebSite","@id":"https:\/\/mklasen.com\/#website","url":"https:\/\/mklasen.com\/","name":"Marinus Klasen","description":"","publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mklasen.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"nl-NL"},{"@type":["Person","Organization"],"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29","name":"Marinus Klasen","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/","url":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","width":1500,"height":1000,"caption":"Marinus Klasen"},"logo":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/"},"description":"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter","sameAs":["http:\/\/facebook.com\/marinus.klasen","https:\/\/nl.linkedin.com\/in\/marinusklasen","https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address.png","featured_image_src":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address-600x400.png","featured_image_src_square":"https:\/\/mklasen.com\/content\/uploads\/2022\/05\/docker-compose-static-ip-address-600x400.png","author_info":{"display_name":"Marinus Klasen","author_link":"https:\/\/mklasen.com\/author\/mklasen\/"},"_links":{"self":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/1141"}],"collection":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/comments?post=1141"}],"version-history":[{"count":2,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/1141\/revisions"}],"predecessor-version":[{"id":1144,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/1141\/revisions\/1144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/media\/1143"}],"wp:attachment":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/media?parent=1141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/categories?post=1141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/tags?post=1141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}