{"id":181,"date":"2024-07-21T11:53:27","date_gmt":"2024-07-21T11:53:27","guid":{"rendered":"https:\/\/dockerpros.com\/?p=181"},"modified":"2024-07-21T11:53:27","modified_gmt":"2024-07-21T11:53:27","slug":"what-is-a-macvlan-network-in-docker","status":"publish","type":"post","link":"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/","title":{"rendered":"What is a macvlan network in Docker?"},"content":{"rendered":"<h2>What is a Macvlan Network in Docker?<\/h2>\n<p>In the world of containerization, Docker has established itself as a leader, enabling developers and system administrators to create, deploy, and manage applications in isolated environments. One of the advanced networking features offered by Docker is the <strong>macvlan<\/strong> <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> pilote. Cet article explore le mode de mise en r\u00e9seau macvlan, ses cas d'utilisation, sa configuration, ses avantages et ses inconv\u00e9nients potentiels, offrant une compr\u00e9hension compl\u00e8te de son fonctionnement et du moment opportun pour le mettre en \u0153uvre dans vos environnements Docker.<\/p>\n<h3>Comprendre le r\u00e9seau Docker<\/h3>\n<p>Before delving into macvlan, it\u2019s essential to grasp Docker\u2019s networking concepts. Docker provides several <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> drivers, each serving a different purpose:<\/p>\n<ol>\n<li><strong>Pont<\/strong>: La valeur par d\u00e9faut <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> driver that isolates containers on a private <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<li><strong>H\u00f4te<\/strong>: Allows containers to share the host&#8217;s <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> <span class=\"glossaryai-tooltip glossary-term-682\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/stack\/\" target=\"_blank\">pile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une pile est une structure de donn\u00e9es qui fonctionne selon le principe du dernier entr\u00e9, premier sorti (LIFO), o\u00f9 l'\u00e9l\u00e9ment le plus r\u00e9cemment ajout\u00e9 est le premier \u00e0 \u00eatre retir\u00e9. Elle prend en charge deux op\u00e9rations principales : empiler et d\u00e9piler.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/stack\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<li><strong>Overlay<\/strong>: Permet aux conteneurs sur plusieurs h\u00f4tes Docker de communiquer de mani\u00e8re s\u00e9curis\u00e9e.<\/li>\n<li><strong>None<\/strong>: Disables all networking for the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<\/ol>\n<p>Each <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> driver serves specific scenarios, but macvlan is unique in that it allows containers to directly connect to the physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, effectively simulating physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> interfaces.<\/p>\n<h3>Qu'est-ce que Macvlan ?<\/h3>\n<p>The macvlan driver allows you to allocate a MAC address to a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, making it appear as a separate physical device on the <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. This approach allows containers to be treated as full-fledged <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> devices, capable of having their own IP addresses, making it particularly useful in scenarios where containers need to be directly accessible from the external <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<h3>Comment fonctionne Macvlan<\/h3>\n<p>Macvlan networks operate at the link layer (Layer 2) of the OSI model, where they can bridge the gap between containers and the physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. When using macvlan, Docker creates virtual <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> interfaces that are tied to the host&#8217;s physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> interface. Here is a simplified view of how macvlan works:<\/p>\n<ol>\n<li>\n<p><strong>Creation of a Macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">R\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: An administrator creates a macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, specifying parameters such as the parent interface (the physical interface that the macvlan will inherit from).<\/p>\n<\/li>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">Conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Connection<\/strong>: When a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is started on a macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, Docker assigns it a MAC address and an IP address that are part of the same subnet as the host&#8217;s interface.<\/p>\n<\/li>\n<li>\n<p><strong>Gestion du trafic<\/strong>: <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">R\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> traffic directed to the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is managed by the macvlan driver, allowing seamless communication with external networks while maintaining isolation from other containers on the same host.<\/p>\n<\/li>\n<\/ol>\n<h3>Creating a Macvlan Network<\/h3>\n<p>To create a macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, you can leverage the Docker CLI. The following command demonstrates how to create a macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-bash\"><span class=\"glossaryai-tooltip glossary-term-1163\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-network-create\/\" target=\"_blank\">docker network create<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">La commande `docker network create` permet aux utilisateurs de cr\u00e9er des r\u00e9seaux personnalis\u00e9s pour les applications conteneuris\u00e9es. Cela facilite une communication et une isolation efficaces entre les conteneurs, am\u00e9liorant ainsi les performances et la s\u00e9curit\u00e9 des applications.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-network-create\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> -d macvlan  \n  --subnet=192.168.1.0\/24  \n  --gateway=192.168.1.1  \n  -o parent=eth0 macvlan0<\/code><\/pre>\n<p>In this command:<\/p>\n<ul>\n<li><code>-d macvlan<\/code>Pr\u00e9cise que vous cr\u00e9ez un <span class=\"glossaryai-tooltip glossary-term-714\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/macvlan-network-driver\/\" target=\"_blank\">macvlan network driver<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le pilote r\u00e9seau MacVLAN permet d'avoir plusieurs adresses MAC sur une seule interface r\u00e9seau, permettant aux conteneurs et aux machines virtuelles de communiquer directement sur le m\u00eame segment r\u00e9seau, am\u00e9liorant ainsi l'isolation et les performances.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/macvlan-network-driver\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<li><code>--sous-r\u00e9seau<\/code>: Sets the subnet for the <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<li><code>--passerelle<\/code>: Defines the gateway for the <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<li><code>-o parent=eth0<\/code>: Indicates the parent interface (in this case, <code>eth0<\/code>).<\/li>\n<\/ul>\n<h3>Connecting Containers to a Macvlan Network<\/h3>\n<p>Once the macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is created, you can connect containers to this <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. This can be done using the following command:<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> -it --r\u00e9seau macvlan0 --nom my_container1 --ip 192.168.1.10 my_image<\/code><\/pre>\n<p>In this command:<\/p>\n<ul>\n<li><code>--network macvlan0<\/code>: Connects the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to the macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> created earlier.<\/li>\n<li><code>--ip 192.168.1.10<\/code>: Assigns a specific IP address to the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/li>\n<\/ul>\n<h3>Cas d'utilisation des r\u00e9seaux Macvlan\n\nLes r\u00e9seaux Macvlan sont une solution efficace pour r\u00e9pondre \u00e0 divers besoins en mati\u00e8re de connectivit\u00e9 r\u00e9seau. Voici quelques cas d'utilisation courants :\n\n1. Virtualisation de serveurs : Les r\u00e9seaux Macvlan permettent de cr\u00e9er plusieurs interfaces virtuelles sur une seule interface physique, ce qui est particuli\u00e8rement utile dans les environnements de virtualisation de serveurs. Chaque machine virtuelle peut ainsi avoir sa propre adresse MAC et son adresse IP, ce qui facilite la gestion du r\u00e9seau et am\u00e9liore les performances.\n\n2. Conteneurs Docker : Les r\u00e9seaux Macvlan sont souvent utilis\u00e9s avec Docker pour attribuer des adresses IP uniques \u00e0 chaque conteneur. Cela permet aux conteneurs de communiquer directement avec le r\u00e9seau externe, comme s'ils \u00e9taient des machines physiques distinctes.\n\n3. Test et d\u00e9veloppement : Les d\u00e9veloppeurs peuvent utiliser les r\u00e9seaux Macvlan pour cr\u00e9er des environnements de test isol\u00e9s qui imitent la structure du r\u00e9seau de production. Cela permet de tester des applications dans des conditions r\u00e9elles sans affecter le r\u00e9seau de production.\n\n4. Surveillance du r\u00e9seau : Les r\u00e9seaux Macvlan peuvent \u00eatre utilis\u00e9s pour surveiller le trafic r\u00e9seau en temps r\u00e9el. En cr\u00e9ant une interface virtuelle distincte pour chaque appareil surveill\u00e9, il est possible d'analyser le trafic de mani\u00e8re plus pr\u00e9cise et d\u00e9taill\u00e9e.\n\n5. S\u00e9curit\u00e9 r\u00e9seau : Les r\u00e9seaux Macvlan peuvent \u00eatre utilis\u00e9s pour impl\u00e9menter des politiques de s\u00e9curit\u00e9 r\u00e9seau plus strictes. En isolant les diff\u00e9rents segments du r\u00e9seau, il est possible de contr\u00f4ler plus efficacement le flux de trafic et de r\u00e9duire les risques de s\u00e9curit\u00e9.\n\n6. Migration de charges de travail : Les r\u00e9seaux Macvlan facilitent la migration de charges de travail entre diff\u00e9rents environnements, car ils permettent de maintenir les m\u00eames adresses IP et configurations r\u00e9seau lors du d\u00e9placement des machines virtuelles ou des conteneurs.\n\n7. R\u00e9seaux d'entreprise : Dans les grandes entreprises, les r\u00e9seaux Macvlan peuvent \u00eatre utilis\u00e9s pour segmenter le r\u00e9seau en fonction des d\u00e9partements ou des fonctions, am\u00e9liorant ainsi la gestion et la s\u00e9curit\u00e9 du r\u00e9seau.\n\n8. Services cloud : Les fournisseurs de services cloud peuvent utiliser les r\u00e9seaux Macvlan pour offrir des options de mise en r\u00e9seau plus flexibles \u00e0 leurs clients, leur permettant de personnaliser leur environnement r\u00e9seau selon leurs besoins sp\u00e9cifiques.\n\n9. Internet des objets (IoT) : Les r\u00e9seaux Macvlan peuvent \u00eatre utilis\u00e9s pour g\u00e9rer les dispositifs IoT en leur attribuant des adresses IP uniques, ce qui facilite la surveillance et la gestion de ces dispositifs au sein du r\u00e9seau.\n\n10. Formation et \u00e9ducation : Dans les environnements \u00e9ducatifs, les r\u00e9seaux Macvlan peuvent \u00eatre utilis\u00e9s pour cr\u00e9er des laboratoires de r\u00e9seau virtuels, permettant aux \u00e9tudiants de pratiquer la configuration et la gestion des r\u00e9seaux sans avoir besoin d'\u00e9quipement physique.\n\nCes cas d'utilisation d\u00e9montrent la polyvalence et l'utilit\u00e9 des r\u00e9seaux Macvlan dans divers contextes, allant de la virtualisation \u00e0 la s\u00e9curit\u00e9 r\u00e9seau, en passant par le d\u00e9veloppement et la formation.<\/h3>\n<p>Le pilote macvlan est particuli\u00e8rement avantageux dans certains sc\u00e9narios :<\/p>\n<ol>\n<li>\n<p><strong>Applications h\u00e9rit\u00e9es<\/strong>: Many legacy applications expect to be configured with their own IP addresses and cannot easily adapt to a shared <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> model. Macvlan allows these applications to <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> in containers while retaining their networking characteristics.<\/p>\n<\/li>\n<li>\n<p><strong>Direct Access to Physical Networks<\/strong>: In environments where direct access to the physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is required (such as VoIP services or monitoring tools), macvlan provides a straightforward solution.<\/p>\n<\/li>\n<li>\n<p><strong>Multiple <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">R\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Interfaces<\/strong>: Containers requiring multiple <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> interfaces on different subnets can use macvlan to achieve this setup easily.<\/p>\n<\/li>\n<li>\n<p><strong>Better Isolation and Security<\/strong>: By assigning containers their own MAC addresses, macvlan provides a layer of isolation, reducing the risk of <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> interference from other containers.<\/p>\n<\/li>\n<li>\n<p><strong>Integration with Existing DHCP Services<\/strong>Macvlan peut fonctionner de mani\u00e8re transparente avec les serveurs DHCP existants, permettant aux conteneurs de recevoir des adresses IP dynamiquement.<\/p>\n<\/li>\n<\/ol>\n<h3>Advantages of Macvlan Networks<\/h3>\n<p>While macvlan networks can be incredibly powerful, they come with several advantages:<\/p>\n<ul>\n<li>\n<p><strong>Direct <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">R\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Acc\u00e8s<\/strong>: Containers can interact directly with the external <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, avoiding the overhead and limitations of traditional Docker networking modes.<\/p>\n<\/li>\n<li>\n<p><strong>Isolation<\/strong>: Each <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can be isolated at the MAC address level, ensuring that broadcast traffic does not interfere with one another.<\/p>\n<\/li>\n<li>\n<p><strong>Gestion facile<\/strong>: Macvlan networks allow for straightforward <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> management, as you can assign IP addresses directly.<\/p>\n<\/li>\n<li>\n<p><strong>Compatibility with <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">R\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Policies<\/strong>: Since containers appear as individual devices, traditional <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> security measures can be applied at the device level.<\/p>\n<\/li>\n<\/ul>\n<h3>Limitations of Macvlan Networks<\/h3>\n<p>Despite its advantages, there are limitations and potential drawbacks to using macvlan networks:<\/p>\n<ul>\n<li>\n<p><strong>Complexit\u00e9 dans la configuration<\/strong>: Setting up macvlan networks can be more complex than bridge networks, especially for new users.<\/p>\n<\/li>\n<li>\n<p><strong>Communication h\u00f4te<\/strong>: Containers on a macvlan cannot communicate with the host system directly. This limitation can complicate scenarios where the host needs to interact with the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<\/li>\n<li>\n<p><strong>Dependency on Physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">R\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: The performance and reliability of macvlan networks depend on the underlying physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Any issues with the physical <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can impact <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> behavior.<\/p>\n<\/li>\n<li>\n<p><strong>Limit\u00e9 \u00e0 la couche 2<\/strong>Les r\u00e9seaux Macvlan fonctionnent au niveau 2, ce qui signifie qu'ils ne prennent pas en charge le routage entre diff\u00e9rents sous-r\u00e9seaux sans configurations suppl\u00e9mentaires.<\/p>\n<\/li>\n<\/ul>\n<h3>Best Practices for Using Macvlan Networks<\/h3>\n<p>Pour maximiser les avantages des r\u00e9seaux macvlan tout en att\u00e9nuant les probl\u00e8mes potentiels, envisagez les bonnes pratiques suivantes :<\/p>\n<ol>\n<li>\n<p><strong>Gestion prudente de la propri\u00e9t\u00e9 intellectuelle<\/strong>: Ensure that the IP addresses assigned to your containers do not conflict with other devices on the <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Use an IP management tool if necessary.<\/p>\n<\/li>\n<li>\n<p><strong>Utilisez des adresses IP statiques lorsque c'est possible.<\/strong>: Bien que macvlan puisse fonctionner avec DHCP, l'utilisation d'adresses IP statiques pour vos conteneurs peut simplifier la gestion et le d\u00e9pannage.<\/p>\n<\/li>\n<li>\n<p><strong>Monitor Performance<\/strong>: Keep an eye on <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> performance and adjust configurations as necessary to prevent bottlenecks.<\/p>\n<\/li>\n<li>\n<p><strong>Firewall Rules<\/strong>: Set up appropriate firewall rules to restrict access to the macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and protect your containers.<\/p>\n<\/li>\n<li>\n<p><strong>Test en environnements non-production<\/strong>: Avant de d\u00e9ployer des r\u00e9seaux macvlan en production, effectuez des tests approfondis pour identifier tout probl\u00e8me potentiel.<\/p>\n<\/li>\n<\/ol>\n<h3>Conclusion<\/h3>\n<p>In summary, the <span class=\"glossaryai-tooltip glossary-term-714\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/macvlan-network-driver\/\" target=\"_blank\">macvlan network driver<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le pilote r\u00e9seau MacVLAN permet d'avoir plusieurs adresses MAC sur une seule interface r\u00e9seau, permettant aux conteneurs et aux machines virtuelles de communiquer directement sur le m\u00eame segment r\u00e9seau, am\u00e9liorant ainsi l'isolation et les performances.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/macvlan-network-driver\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> in Docker offers a robust solution for scenarios requiring direct access to physical networks, isolation, and straightforward management of <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> networking. With its ability to assign unique MAC addresses to containers, macvlan allows for seamless integration with existing networking infrastructures, making it an invaluable tool for developers and system administrators.<\/p>\n<p>However, it is crucial to weigh the advantages against the limitations and complexities associated with macvlan networks. By understanding when and how to implement macvlan, as well as adhering to best practices, you can leverage its powerful capabilities to enhance your Docker environments effectively. Whether you are working with legacy applications, managing complex multi-interface scenarios, or simply seeking a more direct connection to your <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, macvlan presents a viable solution worthy of consideration.<\/p>","protected":false},"excerpt":{"rendered":"<p>Un macvlan <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> in Docker allows containers to have their own MAC addresses, enabling them to appear as individual devices on the <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. This facilitates better <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> isolation and communication with external services.<\/p>","protected":false},"author":1,"featured_media":374,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-181","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-installation-and-configuration"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is a macvlan network in Docker? - Dockerpros<\/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:\/\/dockerpros.com\/fr\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is a macvlan network in Docker? - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"A macvlan network in Docker allows containers to have their own MAC addresses, enabling them to appear as individual devices on the network. This facilitates better network isolation and communication with external services.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-21T11:53:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"dockerpros\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"dockerpros\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\"},\"author\":{\"name\":\"dockerpros\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4\"},\"headline\":\"What is a macvlan network in Docker?\",\"datePublished\":\"2024-07-21T11:53:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\"},\"wordCount\":1089,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg\",\"articleSection\":[\"Installation and Configuration\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\",\"url\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\",\"name\":\"What is a macvlan network in Docker? - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg\",\"datePublished\":\"2024-07-21T11:53:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg\",\"width\":800,\"height\":600,\"caption\":\"what-is-a-macvlan-network-in-docker-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dockerpros.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is a macvlan network in Docker?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dockerpros.com\/#website\",\"url\":\"https:\/\/dockerpros.com\/\",\"name\":\"Dockerpros\",\"description\":\"DockerPros \u2013 Your Ultimate Docker Resource Hub\",\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dockerpros.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"width\":532,\"height\":114,\"caption\":\"Dockerpros\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4\",\"name\":\"dockerpros\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1780577253\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1780577253\",\"caption\":\"dockerpros\"},\"sameAs\":[\"https:\/\/dockerpros.com\/\"],\"url\":\"https:\/\/dockerpros.com\/fr\/author\/dockerpros\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Qu'est-ce qu'un r\u00e9seau macvlan dans Docker ? - Dockerpros\n\nUn r\u00e9seau macvlan est un r\u00e9seau Docker qui permet d'attribuer une adresse MAC et une adresse IP \u00e0 chaque conteneur, ce qui les rend visibles sur le r\u00e9seau physique comme des appareils physiques distincts. Cela permet aux conteneurs d'avoir une connectivit\u00e9 directe avec le r\u00e9seau externe sans passer par le r\u00e9seau interne de Docker.\n\nLes r\u00e9seaux macvlan sont utiles dans les sc\u00e9narios o\u00f9 les conteneurs doivent \u00eatre accessibles directement depuis l'ext\u00e9rieur du r\u00e9seau Docker, par exemple pour h\u00e9berger des services web ou des applications n\u00e9cessitant une adresse IP publique. Ils sont \u00e9galement utiles pour migrer des applications physiques vers des conteneurs sans modifier leur configuration r\u00e9seau.\n\nPour cr\u00e9er un r\u00e9seau macvlan, on utilise la commande `docker network create` avec l'option `--driver macvlan` et en sp\u00e9cifiant l'interface r\u00e9seau physique \u00e0 utiliser. Par exemple :\n\n```bash\ndocker network create -d macvlan --subnet=192.168.1.0\/24 --gateway=192.168.1.1 -o parent=eth0 macvlan-net\n```\n\nCette commande cr\u00e9e un r\u00e9seau macvlan nomm\u00e9 `macvlan-net` utilisant l'interface `eth0` avec le sous-r\u00e9seau `192.168.1.0\/24` et la passerelle `192.168.1.1`.\n\nPour connecter un conteneur \u00e0 ce r\u00e9seau, on utilise la commande `docker run` avec l'option `--network` :\n\n```bash\ndocker run --network macvlan-net -it --name macvlan-container alpine \/bin\/sh\n```\n\nCe conteneur aura une adresse IP du sous-r\u00e9seau `192.168.1.0\/24` et sera directement accessible depuis le r\u00e9seau externe.\n\nIl est important de noter que les r\u00e9seaux macvlan n\u00e9cessitent que l'interface r\u00e9seau physique sous-jacente prenne en charge l'offload de l'adresse MAC. De plus, la configuration du sous-r\u00e9seau et de la passerelle doit correspondre \u00e0 celle du r\u00e9seau physique pour assurer la connectivit\u00e9.","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:\/\/dockerpros.com\/fr\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/","og_locale":"fr_FR","og_type":"article","og_title":"What is a macvlan network in Docker? - Dockerpros","og_description":"A macvlan network in Docker allows containers to have their own MAC addresses, enabling them to appear as individual devices on the network. This facilitates better network isolation and communication with external services.","og_url":"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/","og_site_name":"Dockerpros","article_published_time":"2024-07-21T11:53:27+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg","type":"image\/jpeg"}],"author":"dockerpros","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"dockerpros","Dur\u00e9e de lecture estim\u00e9e":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#article","isPartOf":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/"},"author":{"name":"dockerpros","@id":"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4"},"headline":"What is a macvlan network in Docker?","datePublished":"2024-07-21T11:53:27+00:00","mainEntityOfPage":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/"},"wordCount":1089,"commentCount":0,"publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"image":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg","articleSection":["Installation and Configuration"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/","url":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/","name":"Qu'est-ce qu'un r\u00e9seau macvlan dans Docker ? - Dockerpros\n\nUn r\u00e9seau macvlan est un r\u00e9seau Docker qui permet d'attribuer une adresse MAC et une adresse IP \u00e0 chaque conteneur, ce qui les rend visibles sur le r\u00e9seau physique comme des appareils physiques distincts. Cela permet aux conteneurs d'avoir une connectivit\u00e9 directe avec le r\u00e9seau externe sans passer par le r\u00e9seau interne de Docker.\n\nLes r\u00e9seaux macvlan sont utiles dans les sc\u00e9narios o\u00f9 les conteneurs doivent \u00eatre accessibles directement depuis l'ext\u00e9rieur du r\u00e9seau Docker, par exemple pour h\u00e9berger des services web ou des applications n\u00e9cessitant une adresse IP publique. Ils sont \u00e9galement utiles pour migrer des applications physiques vers des conteneurs sans modifier leur configuration r\u00e9seau.\n\nPour cr\u00e9er un r\u00e9seau macvlan, on utilise la commande `docker network create` avec l'option `--driver macvlan` et en sp\u00e9cifiant l'interface r\u00e9seau physique \u00e0 utiliser. Par exemple :\n\n```bash\ndocker network create -d macvlan --subnet=192.168.1.0\/24 --gateway=192.168.1.1 -o parent=eth0 macvlan-net\n```\n\nCette commande cr\u00e9e un r\u00e9seau macvlan nomm\u00e9 `macvlan-net` utilisant l'interface `eth0` avec le sous-r\u00e9seau `192.168.1.0\/24` et la passerelle `192.168.1.1`.\n\nPour connecter un conteneur \u00e0 ce r\u00e9seau, on utilise la commande `docker run` avec l'option `--network` :\n\n```bash\ndocker run --network macvlan-net -it --name macvlan-container alpine \/bin\/sh\n```\n\nCe conteneur aura une adresse IP du sous-r\u00e9seau `192.168.1.0\/24` et sera directement accessible depuis le r\u00e9seau externe.\n\nIl est important de noter que les r\u00e9seaux macvlan n\u00e9cessitent que l'interface r\u00e9seau physique sous-jacente prenne en charge l'offload de l'adresse MAC. De plus, la configuration du sous-r\u00e9seau et de la passerelle doit correspondre \u00e0 celle du r\u00e9seau physique pour assurer la connectivit\u00e9.","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg","datePublished":"2024-07-21T11:53:27+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/what-is-a-macvlan-network-in-docker_181.jpg","width":800,"height":600,"caption":"what-is-a-macvlan-network-in-docker-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/what-is-a-macvlan-network-in-docker\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dockerpros.com\/"},{"@type":"ListItem","position":2,"name":"What is a macvlan network in Docker?"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Dockerpros","description":"DockerPros \u2013 Votre centre de ressources Docker incontournable","publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dockerpros.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Dockerpros","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","width":532,"height":114,"caption":"Dockerpros"},"image":{"@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4","name":"professionnels Docker","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/#\/schema\/person\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1780577253","contentUrl":"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1780577253","caption":"dockerpros"},"sameAs":["https:\/\/dockerpros.com\/"],"url":"https:\/\/dockerpros.com\/fr\/author\/dockerpros\/"}]}},"_links":{"self":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/posts\/181\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media\/374"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media?parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/categories?post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/tags?post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}