{"id":303,"date":"2020-10-28T15:21:40","date_gmt":"2020-10-28T19:21:40","guid":{"rendered":"https:\/\/blog.jjhayes.net\/wp\/?p=303"},"modified":"2020-10-28T15:32:37","modified_gmt":"2020-10-28T19:32:37","slug":"using-a-macvlan-network-in-docker-compose","status":"publish","type":"post","link":"https:\/\/blog.jjhayes.net\/wp\/2020\/10\/28\/using-a-macvlan-network-in-docker-compose\/","title":{"rendered":"Using a macvlan Network in Docker Compose"},"content":{"rendered":"\n<p>Edit 2020-10-28: <strong>Update docker-compose to v1.27.0+ and you might be able to use IPAM config in a v3 compose file (<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/docker\/compose\/issues\/6569#issuecomment-709195165\" target=\"_blank\">Link<\/a>)<\/strong><\/p>\n\n\n\n<p>Docker Compose v3+ does not support IPAM configuration (<code>gateway<\/code>, <code>ip_range<\/code>, <code>aux_addresses<\/code>) of macvlan networks.<br><br>This network definition used to work in v2, but as v3 targets Docker Swarm use cases, it was removed (NOT deprecated!?):<br><br><code>networks:<br>  home-lan:<br>    name: home-lan<br>    driver: macvlan<br>    driver_opts:<br>      parent: eth0<br>    ipam:<br>      config:<br>        - subnet: 192.168.1.0\/24<br>          ip_range: 192.168.1.0\/24<br>          gateway: 192.168.1.1<\/code><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Use <code>ip_range<\/code> that matches your home network if you&#8217;d like your containers to appear with everything else on that network<\/li><li>DHCP is NOT supported for containers on macvlan networks &#8211; make sure to assign a static <code>ipv4_address<\/code> to the container if you don&#8217;t want it to conflict with something else on your network &#8211; this will create big problems<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">More Info:<\/h2>\n\n\n\n<p>Docker Compose Spec &#8211; IPAM: https:\/\/docs.docker.com\/compose\/compose-file\/#ipam<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Note: Additional IPAM configurations, such as <code>gateway<\/code>, are only honored for version 2 at the moment.<\/p><\/blockquote>\n\n\n\n<p>Docker Macvlan Tutorial: https:\/\/docs.docker.com\/network\/network-tutorial-macvlan\/#prerequisites<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Note: macvlan is NOT supported on Windows hosts<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Related Links:<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Github: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/docker\/compose\/issues\/6569\" target=\"_blank\">Support IPAM gateway in version 3.x<\/a><br>^ Looks like this situation may be fixed in v1.27.0+ of <code>docker-compose<\/code>&#8230;.<\/li><li>Github: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/docker\/compose\/issues\/4474\" target=\"_blank\">docker-compose network ipam config values are not allowed<\/a><\/li><li>Github: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/docker\/compose\/issues\/4366\" target=\"_blank\">version 1.10.0 error on gateway spec<\/a><\/li><li>Github: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/docker\/docker.github.io\/issues\/1528\" target=\"_blank\">Add note that Compose version 3 doesn&#8217;t support additional IPAM configs<\/a><\/li><li>Github: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/docker\/compose\/issues\/3962\" target=\"_blank\">add support for ip-range option to network creation<\/a><\/li><li><\/li><li>Stackoverflow: <a rel=\"noreferrer noopener\" href=\"https:\/\/stackoverflow.com\/questions\/61831255\" target=\"_blank\"><\/a><a href=\"https:\/\/stackoverflow.com\/questions\/61831255\/how-to-create-a-docker-macvlan-with-user-defined-ip-and-mac-address-using-compos\">How to create a Docker macvlan with user defined IP and MAC address using Compose<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Edit 2020-10-28: Update docker-compose to v1.27.0+ and you might be able to use IPAM config in a v3 compose file (Link) Docker Compose v3+ does not support IPAM configuration (gateway, ip_range, aux_addresses) of macvlan networks. This network definition used to work in v2, but as v3 targets Docker Swarm use cases, it was removed (NOT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[45,13],"tags":[46],"class_list":["post-303","post","type-post","status-publish","format-standard","hentry","category-docker","category-software","tag-docker"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3XdjT-4T","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/comments?post=303"}],"version-history":[{"count":3,"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":308,"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/posts\/303\/revisions\/308"}],"wp:attachment":[{"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/media?parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/categories?post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jjhayes.net\/wp\/wp-json\/wp\/v2\/tags?post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}