<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Megha Sharma</title>
    <description>The latest articles on DEV Community by Megha Sharma (@meghasharmaaaa).</description>
    <link>https://dev.to/meghasharmaaaa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1224229%2Fe9190087-8430-46d3-b8a9-e03b75ec2239.png</url>
      <title>DEV Community: Megha Sharma</title>
      <link>https://dev.to/meghasharmaaaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meghasharmaaaa"/>
    <language>en</language>
    <item>
      <title>How Docker Compose works</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Tue, 27 Jan 2026 10:00:04 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/how-compose-works-3fjn</link>
      <guid>https://dev.to/meghasharmaaaa/how-compose-works-3fjn</guid>
      <description>&lt;p&gt;Docker Compose relies on a YAML configuration file, usually named &lt;code&gt;compose.yaml&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;compose.yaml&lt;/code&gt; file follows the rules provided by the Compose Specification in how to define multi-container applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Compose Specification:
&lt;/h2&gt;

&lt;p&gt;The Compose Specification is the latest and recommended version of the Compose file format. It helps you define a Compose file which is used to configure your Docker application’s services, networks, volumes, and more.&lt;/p&gt;

&lt;p&gt;Legacy versions 2.x and 3.x of the Compose file format were merged into the Compose Specification. It is implemented in versions 1.27.0 and above (also known as Compose V2) of the Docker Compose CLI.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 The Compose file
&lt;/h2&gt;

&lt;p&gt;The default path for a Compose file is &lt;code&gt;compose.yaml&lt;/code&gt; (preferred) or &lt;code&gt;compose.yml&lt;/code&gt; that is placed in the working directory. Compose also supports docker-compose.yaml and &lt;code&gt;docker-compose.yml&lt;/code&gt; for backwards compatibility of earlier versions. If both files exist, Compose prefers the canonical &lt;code&gt;compose.yaml&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Multiple Compose files can be merged together to define the application model. The combination of YAML files is implemented by appending or overriding YAML elements based on the Compose file order you set. Simple attributes and maps get overridden by the highest order Compose file, lists get merged by appending. Relative paths are resolved based on the first Compose file’s parent folder, whenever complimentary files being merged are hosted in other folders. As some Compose file elements can both be expressed as single strings or complex objects, merges apply to the expanded form.&lt;/p&gt;

&lt;p&gt;If you want to reuse other Compose files, or factor out parts of your application model into separate Compose files, you can also use include. This is useful if your Compose application is dependent on another application which is managed by a different team, or needs to be shared with others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Consider an application split into a frontend web application and a backend service.&lt;/p&gt;

&lt;p&gt;The frontend is configured at runtime with an HTTP configuration file managed by infrastructure, providing an external domain name, and an HTTPS server certificate injected by the platform’s secured secret store.&lt;/p&gt;

&lt;p&gt;And The backend stores data in a persistent volume.&lt;/p&gt;

&lt;p&gt;Both services communicate with each other on an isolated back-tier network, while the frontend is also connected to a front-tier network and exposes port 443 for external usage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo2vtc4aj4uy7cx2icmko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo2vtc4aj4uy7cx2icmko.png" alt=" " width="800" height="304"&gt;&lt;/a&gt;&lt;br&gt;
The example application is composed of the following parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2 services, backed by Docker images: webapp and database&lt;/li&gt;
&lt;li&gt;1 secret (HTTPS certificate), injected into the frontend&lt;/li&gt;
&lt;li&gt;1 configuration (HTTP), injected into the frontend&lt;/li&gt;
&lt;li&gt;1 persistent volume, attached to the backend&lt;/li&gt;
&lt;li&gt;2 networks
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;services:
  frontend:
    image: example/webapp
    ports:
      - "443:8043"
    networks:
      - front-tier
      - back-tier
    configs:
      - httpd-config
    secrets:
      - server-certificate

  backend:
    image: example/database
    volumes:
      - db-data:/etc/data
    networks:
      - back-tier

volumes:
  db-data:
    driver: flocker
    driver_opts:
      size: "10GiB"

configs:
  httpd-config:
    external: true

secrets:
  server-certificate:
    external: true

networks:
  # The presence of these objects is sufficient to define them
  front-tier: {}
  back-tier: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let’s break down each part of the Docker Compose file you provided step by step:&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Services Section:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;frontend:&lt;/code&gt; This section defines a service named &lt;code&gt;frontend&lt;/code&gt;. It uses the Docker image &lt;code&gt;example/webapp&lt;/code&gt; to create containers. The service exposes port &lt;code&gt;443&lt;/code&gt; of the container to port &lt;code&gt;8043&lt;/code&gt; on the host machine. This means that incoming traffic on port &lt;code&gt;8043&lt;/code&gt; of the host will be directed to port &lt;code&gt;443&lt;/code&gt; inside the container running the &lt;code&gt;frontend&lt;/code&gt; service.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ports:&lt;/code&gt; Maps the host machine's port &lt;code&gt;8043&lt;/code&gt; to the container's port &lt;code&gt;443&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;networks:&lt;/code&gt; Connects the &lt;code&gt;frontend&lt;/code&gt; service to two Docker networks: &lt;code&gt;front-tier&lt;/code&gt; and &lt;code&gt;back-tier&lt;/code&gt;. This allows the &lt;code&gt;frontend&lt;/code&gt; service to communicate with other services connected to these networks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;configs:&lt;/code&gt; Associates the &lt;code&gt;frontend&lt;/code&gt; service with an external configuration named &lt;code&gt;httpd-config&lt;/code&gt;. This configuration likely contains settings for an HTTP server like Apache.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;secrets:&lt;/code&gt; Links the &lt;code&gt;frontend&lt;/code&gt; service with an external secret named &lt;code&gt;server-certificate&lt;/code&gt;. This secret probably contains &lt;code&gt;SSL certificates&lt;/code&gt; or other sensitive information needed by the web server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;backend:&lt;/code&gt; This section defines a service named &lt;code&gt;backend&lt;/code&gt; that uses the Docker image &lt;code&gt;example/database&lt;/code&gt; to create containers. The backend service is simpler compared to frontend.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;volumes:&lt;/code&gt; Mounts a Docker volume named &lt;code&gt;db-data&lt;/code&gt; to the container's &lt;code&gt;/etc/data&lt;/code&gt; directory. This volume is used to persist data for the database service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;networks:&lt;/code&gt; Connects the &lt;code&gt;backend&lt;/code&gt; service to the &lt;code&gt;back-tier&lt;/code&gt; Docker network. This network likely facilitates communication between backend services.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👉 Volumes Section:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;db-data:&lt;/code&gt; Defines a Docker volume named &lt;code&gt;db-data&lt;/code&gt; using the Flocker driver. The volume's driver options specify a size of &lt;code&gt;10GiB&lt;/code&gt;. This volume is used by the &lt;code&gt;backend&lt;/code&gt; service to store data persistently.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Configs Section:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;httpd-config:&lt;/code&gt; Specifies an external configuration named &lt;code&gt;httpd-config&lt;/code&gt;. This configuration is likely used by the &lt;code&gt;frontend&lt;/code&gt; service, possibly containing settings for an Apache HTTP server.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Secrets Section:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;server-certificate:&lt;/code&gt; Specifies an external secret named &lt;code&gt;server-certificate&lt;/code&gt;. This secret is used by the &lt;code&gt;frontend&lt;/code&gt; service, possibly containing SSL certificates or other sensitive information required by the web server.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Networks Section:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;front-tier and back-tier:&lt;/code&gt; Defines two Docker networks named &lt;code&gt;front-tier&lt;/code&gt; and &lt;code&gt;back-tier&lt;/code&gt;. Although the definition in the file is empty, referencing these networks within services automatically creates and connects containers to them. These networks enable communication between services and provide isolation and segmentation within the Docker environment.&lt;/p&gt;

&lt;p&gt;This Docker Compose file sets up a frontend web application (&lt;code&gt;frontend&lt;/code&gt; service) with a specific image, ports, networks, configurations, and secrets. It also includes a backend database (&lt;code&gt;backend&lt;/code&gt; service) with its own image, volume, and network configurations. The file ensures that the necessary volumes, configurations, secrets, and networks are available for the services to function properly within the Docker environment.&lt;/p&gt;

&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/installing-docker-compose-3i83"&gt;Installing Docker Compose&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>containers</category>
      <category>learning</category>
    </item>
    <item>
      <title>Installing Docker Compose</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Wed, 21 Jan 2026 09:51:40 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/installing-docker-compose-3i83</link>
      <guid>https://dev.to/meghasharmaaaa/installing-docker-compose-3i83</guid>
      <description>&lt;p&gt;Here are three common scenarios for installing Docker Compose:&lt;/p&gt;

&lt;h2&gt;
  
  
  Scenario one: Install Docker Desktop
&lt;/h2&gt;

&lt;p&gt;The easiest and recommended way to get Docker Compose is to install Docker Desktop. Docker Desktop includes Docker Compose along with Docker Engine and Docker CLI which are Compose prerequisites.&lt;/p&gt;

&lt;p&gt;Docker Desktop is available on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;Mac&lt;/li&gt;
&lt;li&gt;Windows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have already installed Docker Desktop, you can check which version of Compose you have by selecting About Docker Desktop from the Docker menu.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scenario two: Install the Compose plugin
&lt;/h2&gt;

&lt;p&gt;If you already have Docker Engine and Docker CLI installed, you can install the Compose plugin from the command line, by either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using Docker’s repository&lt;/li&gt;
&lt;li&gt;Downloading and installing manually&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Scenario three: Install the Compose standalone
&lt;/h2&gt;

&lt;p&gt;You can install the Compose standalone on Linux or on Windows Server.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyedlslgs0lpwyx2t9o54.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyedlslgs0lpwyx2t9o54.jpg" alt=" " width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  👉 Install the Docker Compose plugin:
&lt;/h2&gt;

&lt;p&gt;To install the Compose plugin on Linux, you can either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up Docker’s repository on your Linux system.&lt;/li&gt;
&lt;li&gt;Install Compose manually.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  👉 Install using the repository:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Set up the repository. Find distro-specific instructions in:&lt;br&gt;
Ubuntu | CentOS | Debian | Raspberry Pi OS | Fedora | RHEL | SLES.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the package index, and install the latest version of Docker Compose:&lt;br&gt;
For Ubuntu and Debian, run:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get update
$ sudo apt-get install docker-compose-plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;For RPM-based distros, run:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo yum update
$ sudo yum install docker-compose-plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Verify that Docker Compose is installed correctly by checking the version.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker compose version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Expected output:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Docker Compose version vN.N.N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Where vN.N.N is placeholder text standing in for the latest version.&lt;/p&gt;
&lt;h2&gt;
  
  
  👉 Install the plugin manually:
&lt;/h2&gt;

&lt;p&gt;To download and install the Compose CLI plugin, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
$ mkdir -p $DOCKER_CONFIG/cli-plugins
$ curl -SL https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command downloads the latest release of Docker Compose (from the Compose releases repository) and installs Compose for the active user under &lt;code&gt;$HOME&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;To install:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker Compose for all users on your system, replace &lt;code&gt;~/.docker/cli-plugins&lt;/code&gt; with &lt;code&gt;/usr/local/lib/docker/cli-plugins&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A different version of Compose, substitute &lt;code&gt;v2.26.1&lt;/code&gt; with the version of Compose you want to use.&lt;/li&gt;
&lt;li&gt;For a different architecture, substitute &lt;code&gt;x86_64&lt;/code&gt; with the architecture you want.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apply executable permissions to the binary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or, if you chose to install Compose for all users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker compose version


Docker Compose version v2.26.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👉 Install Compose standalone
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;On Linux:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To download and install Compose standalone, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -SL https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply executable permissions to the standalone binary in the target path for the installation.&lt;/p&gt;

&lt;p&gt;Test and execute compose commands using &lt;code&gt;docker-compose&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On Windows Server:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Follow these instructions if you are running the Docker daemon and client directly on Microsoft Windows Server and want to install Docker Compose.&lt;/p&gt;

&lt;p&gt;GitHub now requires TLS1.2. In PowerShell, run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12Run PowerShell as an administrator. When asked if you want to allow this app to make changes to your device, select Yes in order to proceed with the installation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following command to download the latest release of Compose (v2.26.1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Start-BitsTransfer -Source "https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-windows-x86_64.exe" -Destination $Env:ProgramFiles\Docker\docker-compose.exe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose.exe version


Docker Compose version v2.26.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👉 Uninstall Docker Compose
&lt;/h2&gt;

&lt;p&gt;Uninstalling Docker Compose depends on the method you have used to install Docker Compose.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uninstalling the Docker Compose CLI plugin:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To remove the Compose CLI plugin, run:&lt;br&gt;
Ubuntu, Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get remove docker-compose-plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;RPM-based distros:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo yum remove docker-compose-plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Manually installed:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you used &lt;code&gt;curl&lt;/code&gt; to install Compose CLI plugin, to uninstall it, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rm $DOCKER_CONFIG/cli-plugins/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove for all users:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or, if you have installed Compose for all users, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rm /usr/local/lib/docker/cli-plugins/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Inspect the location of the Compose CLI plugin:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check where Compose is installed, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/docker-compose-overview-2c2h"&gt;Docker Compose overview&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>learning</category>
      <category>containers</category>
      <category>community</category>
    </item>
    <item>
      <title>Docker Compose overview</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Sun, 11 Jan 2026 10:27:02 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/docker-compose-overview-2c2h</link>
      <guid>https://dev.to/meghasharmaaaa/docker-compose-overview-2c2h</guid>
      <description>&lt;p&gt;Docker Compose is a tool that simplifies the management of multi-container Docker applications. It allows you to define and run multi-container Docker applications using a single YAML file.&lt;/p&gt;

&lt;p&gt;Docker Compose is a tool for defining and running multi-container applications. It is the key to unlocking a streamlined and efficient development and deployment experience.&lt;/p&gt;

&lt;p&gt;Compose simplifies the control of your entire application stack, making it easy to manage services, networks, and volumes in a single, comprehensible YAML configuration file. Then, with a single command, you create and start all the services from your configuration file.&lt;/p&gt;

&lt;p&gt;Compose works in all environments; production, staging, development, testing, as well as CI workflows. It also has commands for managing the whole lifecycle of your application:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start, stop, and rebuild services&lt;/li&gt;
&lt;li&gt;View the status of running services&lt;/li&gt;
&lt;li&gt;Stream the log output of running services&lt;/li&gt;
&lt;li&gt;Run a one-off command on a service&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👉 Key benefits of Docker Compose
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmm5x3wrzlm1anlsaf4r6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmm5x3wrzlm1anlsaf4r6.jpg" alt=" " width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using Docker Compose offers several benefits that streamline the development, deployment, and management of containerized applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simplified control:&lt;/strong&gt; Docker Compose allows you to define and manage multi-container applications in a single YAML file. This simplifies the complex task of orchestrating and coordinating various services, making it easier to manage and replicate your application environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Efficient collaboration:&lt;/strong&gt; Docker Compose configuration files are easy to share, facilitating collaboration among developers, operations teams, and other stakeholders. This collaborative approach leads to smoother workflows, faster issue resolution, and increased overall efficiency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rapid application development:&lt;/strong&gt; Compose caches the configuration used to create a container. When you restart a service that has not changed, Compose re-uses the existing containers. Re-using containers means that you can make changes to your environment very quickly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Portability across environments:&lt;/strong&gt; Compose supports variables in the Compose file. You can use these variables to customize your composition for different environments, or different users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensive community and support:&lt;/strong&gt; Docker Compose benefits from a vibrant and active community, which means abundant resources, tutorials, and support. This community-driven ecosystem contributes to the continuous improvement of Docker Compose and helps users troubleshoot issues effectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security if internal container network:&lt;/strong&gt; In Docker Compose, all containers specified in the compose file are connected to the same internal network, shielding them from unauthorized access. It not only enhances security but also streamlines network management for multi-container applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Host Isolation:&lt;/strong&gt; Isolation is paramount in containerized environments, and Docker Compose provides a level of isolation by encapsulating each application component within its container. This prevents conflicts between dependencies and ensures that changes made to one component do not affect others. Docker Compose allows developers to define network and volume configurations, further enhancing isolation and security.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👉 Common use cases of Docker Compose
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk5ph2l4vepuek5y1iww.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk5ph2l4vepuek5y1iww.jpg" alt=" " width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚪ Development environments:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker Compose is extensively used for creating consistent and reproducible development environments. Developers define their application’s stack, including services like databases, web servers, caching systems, etc., in a Compose file. This allows team members to easily set up the development environment with a single command (&lt;code&gt;docker-compose up&lt;/code&gt;) and ensures that everyone works in an environment that closely resembles production.&lt;/p&gt;

&lt;p&gt;When you’re developing software, the ability to run an application in an isolated environment and interact with it is crucial. The Compose command line tool can be used to create the environment and interact with it.&lt;/p&gt;

&lt;p&gt;The Compose file provides a way to document and configure all of the application’s service dependencies (databases, queues, caches, web service APIs, etc). Using the Compose command line tool you can create and start one or more containers for each dependency with a single command (&lt;code&gt;docker compose up&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Together, these features provide a convenient way for you to get started on a project. Compose can reduce a multi-page “developer getting started guide” to a single machine-readable Compose file and a few commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚪ Automated testing environments:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compose is valuable for setting up isolated testing environments. Testers can use Docker Compose to deploy the application stack for integration testing, regression testing, or performance testing. By defining the entire environment in a Compose file, testing teams can ensure that tests are conducted in a consistent and controlled environment.&lt;/p&gt;

&lt;p&gt;An important part of any Continuous Deployment or Continuous Integration process is the automated test suite. Automated end-to-end testing requires an environment in which to run tests. Compose provides a convenient way to create and destroy isolated testing environments for your test suite. By defining the full environment in a Compose file, you can create and destroy these environments in just a few commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker compose up -d
$ ./run_tests
$ docker compose down
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚪ &lt;strong&gt;Local Development and Debugging:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers use Docker Compose for local development and debugging of multi-container applications. It allows them to run the application stack locally on their machines, making it easy to test changes, debug issues, and iterate rapidly. The containerized environment closely mirrors the production environment, reducing discrepancies between development and production environments.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Continuous Integration/Continuous Deployment (CI/CD):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker Compose is a key component of CI/CD pipelines for Dockerized applications. CI systems such as Jenkins, GitLab CI/CD, or GitHub Actions can use Compose to define and deploy application stacks for automated testing, building Docker images, running integration tests, and deploying to staging or production environments. This ensures consistency and reliability throughout the deployment pipeline.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Microservices Architecture:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a microservices architecture, Docker Compose helps in orchestrating multiple microservices that work together to form a larger application. Each microservice can be defined as a separate container within the Compose file, allowing developers to manage the interactions and dependencies between services efficiently. Compose facilitates the development, testing, and deployment of microservices-based applications.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Demo and Training Environments:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compose is useful for creating demo environments or training environments where users need to quickly deploy and interact with a pre-configured application stack. It simplifies the setup process and allows trainers or presenters to demonstrate the application’s functionality without worrying about complex setup procedures.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Prototyping and Proof of Concept (PoC):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker Compose is valuable for quickly prototyping and building proof of concepts for new projects or features. Developers can define a basic architecture using Compose, test different configurations, and iterate rapidly to validate ideas before investing significant resources in full-scale development.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Deployment for Small-scale Applications:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Docker Compose is primarily designed for local development and testing, it can also be used for deploying small-scale applications in production environments, especially in scenarios where orchestration platforms like Docker Swarm or Kubernetes might be overkill. Compose allows for straightforward deployment and management of containerized applications on single-node hosts.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;production Environments:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you define your app with Compose in development, you can use this definition to run your application in different environments such as CI, staging, and production.&lt;/p&gt;

&lt;p&gt;The easiest way to deploy an application is to run it on a single server, similar to how you would run your development environment. If you want to scale up your application, you can run Compose apps on a Swarm cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉History and development of Docker Compose
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegoopivhus5ss1ujz0s2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegoopivhus5ss1ujz0s2.png" alt=" " width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows that the currently supported version of the Docker Compose CLI is Compose V2 which is defined by the Compose Specification.&lt;/p&gt;

&lt;p&gt;It also provides a quick snapshot of the differences in file formats, command-line syntax, and top-level elements. This is covered in more detail in the following sections.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Docker Compose CLI versioning:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Version one of the Docker Compose command-line binary was first released in 2014. It was written in Python, and is invoked with &lt;code&gt;docker-compose&lt;/code&gt;. Typically, Compose V1 projects include a top-level &lt;code&gt;version&lt;/code&gt; element in the &lt;code&gt;compose.yml&lt;/code&gt; file, with values ranging from &lt;code&gt;2.0&lt;/code&gt; to &lt;code&gt;3.8&lt;/code&gt;, which refer to the specific file formats.&lt;/p&gt;

&lt;p&gt;Version two of the Docker Compose command-line binary was announced in 2020, is written in Go, and is invoked with &lt;code&gt;docker compose&lt;/code&gt;. Compose V2 ignores the &lt;code&gt;version&lt;/code&gt; top-level element in the &lt;code&gt;compose.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;⚪ &lt;strong&gt;Compose file format versioning:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Docker Compose CLIs are defined by specific file formats.&lt;/p&gt;

&lt;p&gt;Three major versions of the Compose file format for Compose V1 were released:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compose file format 1 with Compose 1.0.0 in 2014&lt;/li&gt;
&lt;li&gt;Compose file format 2.x with Compose 1.6.0 in 2016&lt;/li&gt;
&lt;li&gt;Compose file format 3.x with Compose 1.10.0 in 2017&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compose file format 1 is substantially different to all the following formats as it lacks a top-level &lt;code&gt;services key&lt;/code&gt;. Its usage is historical and files written in this format don't run with Compose V2.&lt;/p&gt;

&lt;p&gt;Compose file format 2.x and 3.x are very similar to each other, but the latter introduced many new options targeted at Swarm deployments.&lt;/p&gt;

&lt;p&gt;To address confusion around Compose CLI versioning, Compose file format versioning, and feature parity depending on whether Swarm mode was in use, file format 2.x and 3.x were merged into the Compose Specification.&lt;/p&gt;

&lt;p&gt;Compose V2 uses the Compose Specification for project definition. Unlike the prior file formats, the Compose Specification is rolling and makes the &lt;code&gt;version&lt;/code&gt; top-level element optional. Compose V2 also makes use of optional specifications - Deploy, Develop and Build.&lt;/p&gt;

&lt;p&gt;To make migration easier, Compose V2 has backwards compatibility for certain elements that have been deprecated or changed between Compose file format 2.x/3.x and the Compose Specification.&lt;/p&gt;

&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/docker-network-commands-3878"&gt;Docker Network Commands&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>devops</category>
      <category>learning</category>
    </item>
    <item>
      <title>Docker Network Commands</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Fri, 02 Jan 2026 12:08:49 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/docker-network-commands-3878</link>
      <guid>https://dev.to/meghasharmaaaa/docker-network-commands-3878</guid>
      <description>&lt;p&gt;The &lt;code&gt;docker network&lt;/code&gt; command is used to manage Docker networks. It allows you to create, inspect, list, connect, disconnect, and remove Docker networks. Below are some common subcommands and examples of using the &lt;code&gt;docker network&lt;/code&gt; command:&lt;/p&gt;

&lt;h2&gt;
  
  
  👉List Docker Networks:
&lt;/h2&gt;

&lt;p&gt;This command provides a list of all networks created on your Docker host. Here’s how you can use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run this command, Docker will output a table with information about each network, including its ID, name, driver, and scope (local or global). The output will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NETWORK ID     NAME            DRIVER    SCOPE
abcdef123456   bridge          bridge    local
ghijkl789012   host            host      local
mnopqr345678   my-network      bridge    local
stuvwx901234   my-overlay-net  overlay   swarm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;NETWORK ID:&lt;/code&gt; Unique identifier for each network.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NAME:&lt;/code&gt; Name of the network.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DRIVER:&lt;/code&gt; The type of driver used for the network (e.g., bridge, overlay, host).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SCOPE:&lt;/code&gt; Specifies whether the network is local (only accessible on the current host) or global (accessible across multiple hosts in a swarm).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;docker network ls&lt;/code&gt; command is useful for quickly checking the existing Docker networks on your system and their basic properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Inspect a Docker Network:
&lt;/h2&gt;

&lt;p&gt;To inspect a Docker network and view detailed information about it, you can use the &lt;code&gt;docker network inspect&lt;/code&gt;command followed by the network's name or ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network inspect NETWORK_NAME_OR_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;NETWORK_NAME_OR_ID&lt;/code&gt; with the actual &lt;code&gt;name&lt;/code&gt; or &lt;code&gt;ID&lt;/code&gt; of the Docker network you want to inspect. For example, if you want to inspect a network named &lt;code&gt;my-network&lt;/code&gt;, you would use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network inspect my-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output of the &lt;code&gt;docker network inspect&lt;/code&gt; command provides comprehensive details about the specified network, including its configuration, containers connected to it, IP address ranges, and more. The information is presented in JSON format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of the output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {
        "Name": "my-network",
        "Id": "abcdef1234567890",
        "Created": "2022-01-01T12:00:00Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "container1": {
                "Name": "container1",
                "EndpointID": "xyz123456789",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            },
            "container2": {
                "Name": "container2",
                "EndpointID": "abc987654321",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output contains information such as the network’s name, ID, creation time, driver, IP address management (IPAM) configuration, connected containers, and additional options. This information can be useful for troubleshooting, managing network configurations, or understanding network settings in Docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉Create a Docker Network:
&lt;/h2&gt;

&lt;p&gt;To create a Docker network, you can use the &lt;code&gt;docker network create&lt;/code&gt; command followed by the desired options and the name you want to give to the network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create my-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a Docker network named &lt;code&gt;my-network&lt;/code&gt; using the default bridge driver and default options. If you want to specify additional options, such as the network driver, subnet, gateway, or other configurations, you can include those options in the command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s an example of creating a Docker network with custom options:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create \
  --driver bridge \
  --subnet 172.18.0.0/16 \
  --gateway 172.18.0.1 \
  --ip-range 172.18.0.0/24 \
  my-custom-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--driver bridge&lt;/code&gt;: Specifies the network driver as bridge. You can use &lt;br&gt;
other drivers like overlay, macvlan, etc., based on your requirements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--subnet 172.18.0.0/16&lt;/code&gt;: Defines the subnet for the network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--gateway 172.18.0.1&lt;/code&gt;: Specifies the gateway IP address for the network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--ip-range 172.18.0.0/24&lt;/code&gt;: Defines the range of IP addresses that can be assigned to containers on this network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;my-custom-network&lt;/code&gt;: The name given to the network.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the &lt;code&gt;docker network create&lt;/code&gt; command, Docker will create the specified network with the provided configurations. You can verify the network's creation by using the &lt;code&gt;docker network ls&lt;/code&gt; command to list all networks on your Docker host.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Connect a Container to a Network:
&lt;/h2&gt;

&lt;p&gt;To connect a Docker container to a network, you can use the &lt;code&gt;docker network connect&lt;/code&gt; command followed by the network name and the container name or ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network connect my-network my-container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;my-network&lt;/code&gt; is the name of the network to which you want to connect the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-container&lt;/code&gt; is the name or ID of the container you want to connect to the network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running this command, the specified container (&lt;code&gt;my-container&lt;/code&gt;) will be connected to the &lt;code&gt;my-network&lt;/code&gt; network. This allows the container to communicate with other containers on the same network using their container names or IP addresses within the network.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Disconnect a Container from a Network:
&lt;/h2&gt;

&lt;p&gt;To disconnect a Docker container from a network, you can use the &lt;code&gt;docker network disconnect&lt;/code&gt; command followed by the network name and the container name or ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network disconnect my-network my-container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;my-network&lt;/code&gt; is the name of the network from which you want to disconnect the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-container&lt;/code&gt; is the name or ID of the container you want to disconnect from the network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running this command, the specified container (&lt;code&gt;my-container&lt;/code&gt;) will be disconnected from the &lt;code&gt;my-network&lt;/code&gt; network. This means that the container will no longer be able to communicate with other containers on that network, although it may still be connected to other networks or have its own network namespace.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉Remove a Docker Network:
&lt;/h2&gt;

&lt;p&gt;To remove a Docker network, you can use the &lt;code&gt;docker network rm&lt;/code&gt; command followed by the name or ID of the network you want to remove.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network rm my-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;my-network&lt;/code&gt; is the name of the Docker network you want to remove.&lt;/p&gt;

&lt;p&gt;After running this command, Docker will delete the specified network (&lt;code&gt;my-network&lt;/code&gt;). Any containers connected exclusively to this network will be disconnected from it. However, if a container is connected to multiple networks and one of them is removed, the container remains connected to the other networks.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 docker network prune:
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;docker network prune&lt;/code&gt; command is used to remove all unused Docker networks from your system. Unused networks are those that are not connected to any containers. This command helps clean up your Docker environment by removing networks that are no longer in use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run d&lt;code&gt;ocker network prune&lt;/code&gt; without any options, Docker will prompt you to confirm whether you want to remove all unused networks. You can type y and press Enter to proceed with the removal.&lt;/p&gt;

&lt;p&gt;If you want to skip the confirmation prompt, you can use the &lt;code&gt;-f&lt;/code&gt; or &lt;code&gt;--force&lt;/code&gt; option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network prune -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will immediately remove all unused networks without asking for confirmation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; - It’s important to note that the &lt;code&gt;docker network prune&lt;/code&gt; command only removes unused networks. Networks that are still in use by one or more containers will not be removed.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉docker network create-ipam:
&lt;/h2&gt;

&lt;p&gt;The d&lt;code&gt;ocker network create-ipam&lt;/code&gt; command is used to create a new IP address management (IPAM) configuration for a Docker network. IPAM allows you to define custom IP address ranges, subnets, gateways, and other network configurations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create-ipam --subnet=192.168.1.0/24 my-custom-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--subnet=192.168.1.0/24&lt;/code&gt; specifies the subnet for the new IPAM configuration. You can adjust the subnet to match your network requirements.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-custom-network&lt;/code&gt; is the name given to the Docker network for which you are creating the custom IPAM configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the &lt;code&gt;docker network create-ipam&lt;/code&gt; command, Docker will create a new IPAM configuration with the specified subnet for the &lt;code&gt;my-custom-network&lt;/code&gt; Docker network. This allows you to define specific IP address ranges and network settings for containers connected to this network.&lt;/p&gt;

&lt;p&gt;It’s worth noting that custom IPAM configurations are optional, and Docker provides default IPAM settings for networks created without specifying custom configurations. Custom IPAM configurations are useful for advanced networking scenarios where you need precise control over IP address allocation and network parameters.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉docker network connect-ipam:
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;docker network connect-ipam&lt;/code&gt; command is used to connect a container to a Docker network with a custom IP address management (IPAM) configuration. IPAM allows you to define specific IP address ranges, subnets, gateways, and other network settings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network connect-ipam --ip=192.168.1.10 my-custom-network my-container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--ip=192.168.1.10&lt;/code&gt; specifies the IP address that you want to assign to the container on the connected network. You can adjust the IP address as needed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-custom-network&lt;/code&gt; is the name of the Docker network with a custom IPAM configuration to which you want to connect the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-container&lt;/code&gt; is the name or ID of the container you want to connect to the network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the &lt;code&gt;docker network connect-ipam&lt;/code&gt;command, Docker will connect the specified container (&lt;code&gt;my-container&lt;/code&gt;) to the &lt;code&gt;my-custom-network&lt;/code&gt; Docker network with the custom IPAM configuration. The container will be assigned the specified IP address (&lt;code&gt;192.168.1.10&lt;/code&gt;) on the network.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;docker network connect-ipam&lt;/code&gt; command with custom IPAM configurations allows you to have more control over IP address assignment and network parameters for containers connected to your Docker networks.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉docker network disconnect-ipam:
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;docker network disconnect-ipam&lt;/code&gt; command is used to disconnect a container from a Docker network that has a custom IP address management (IPAM) configuration. This command is specifically designed for networks with custom IPAM settings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network disconnect-ipam my-custom-network my-container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;my-custom-network&lt;/code&gt; is the name of the Docker network with a custom IPAM configuration from which you want to disconnect the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-container&lt;/code&gt; is the name or ID of the container you want to disconnect from the network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the &lt;code&gt;docker network disconnect-ipam&lt;/code&gt; command, Docker will disconnect the specified container (&lt;code&gt;my-container&lt;/code&gt;) from the my-custom-network Docker network with the custom IPAM configuration.&lt;/p&gt;

&lt;p&gt;It’s important to note that the &lt;code&gt;docker network disconnect-ipam&lt;/code&gt; command is specifically used for networks with custom IPAM configurations. For networks with default IPAM settings, you would use the regular &lt;code&gt;docker network disconnect&lt;/code&gt; command without the &lt;code&gt;-ipam&lt;/code&gt; suffix.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Example:
&lt;/h2&gt;

&lt;p&gt;By default when the bridge network is created, the DNS is not enabled. But if we create our custom bridge network DNS is enabled by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loclhost:~$ docker container ls
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

localhost:~$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
6c51373f78ad   bridge    bridge    local
3a33f83c3664   host      host      local
e4ebd601732e   none      null      local

localhost:~$ docker container run -itd ubuntu:14.04 bash
7b1af2ee48e43f8018c4324bbcb9f52a27f741bd7a0437ddd0f6766bd7ca6b10

localhost:~$ docker container run -itd ubuntu:14.04 bash
c3ce5dbe5d859705f139e811bc11367d02bf0969492e9d515a3cc6cc636ddfbb

localhost:~$ docker container ls
CONTAINER ID   IMAGE          COMMAND   CREATED          STATUS         PORTS     NAMES
c3ce5dbe5d85   ubuntu:14.04   "bash"    8 seconds ago    Up 7 seconds             unruffled_sinoussi
7b1af2ee48e4   ubuntu:14.04   "bash"    10 seconds ago   Up 9 seconds             trusting_joliot

localhost:~$ docker container exec -it 7b bash
root@7b1af2ee48e4:/# ping c3ce5dbe5d85

ping: unknown host c3ce5dbe5d85
root@7b1af2ee48e4:/#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To achieve the above use case, let’s create a network &lt;code&gt;test&lt;/code&gt; first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localhost:~$ docker network create test
b1e05c1afdb2f901e81a66a52d64a9dcdca9c5cab98433cdaed2faa83c5b3e6b

localhost:~$ docker container ls
CONTAINER ID   IMAGE     COMMAND   CREATED              STATUS              PORTS     NAMES

localhost:~$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, create a container with ubuntu image with network as &lt;code&gt;test&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localhost:~$ docker container run -itd --network=test ubuntu:14.04 bash
c7b07b61bb20cdbb6e1b54a165aed0f8907d95d563fdd7a60940d004694c4557
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List the containers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localhost:~$ docker container ls
CONTAINER ID   IMAGE     COMMAND   CREATED              STATUS              PORTS     NAMES
c7b07b61bb20   ubuntu    "bash"    About a minute ago   Up About a minute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the container using inspect command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Networks": {
                "host": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "b1e05c1afdb2f901e81a66a52d64a9dcdca9c5cab98433cdaed2faa83c5b3e6b",
                    "EndpointID": "b860ca4fdda3e0732367949cb94fd2eded08a4f2e46715a6c125b1bf336c102f",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete a Network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localhost:~$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
6c51373f78ac   bridge    bridge    local
3a33f83c3663   host      host      local
e4ebd601732c   none      null      local
348f7295d3ca   test      bridge    local

localhost:~$ docker network rm test
test

localhost:~$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/what-is-none-network-driver-3pmi"&gt;What is None network driver&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>opensource</category>
      <category>development</category>
    </item>
    <item>
      <title>What is None network driver</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Thu, 25 Dec 2025 11:49:32 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/what-is-none-network-driver-3pmi</link>
      <guid>https://dev.to/meghasharmaaaa/what-is-none-network-driver-3pmi</guid>
      <description>&lt;p&gt;The &lt;code&gt;none&lt;/code&gt;network driver in Docker is a special type of network that provides complete isolation for a container from any external network. When you attach a container to the &lt;code&gt;none&lt;/code&gt; network, it means the container has no network connectivity whatsoever. This can be useful in certain scenarios where you want to prevent a container from communicating with other containers or external networks.&lt;/p&gt;

&lt;p&gt;If you want to completely isolate the networking stack of a container, you can use the &lt;code&gt;--network none&lt;/code&gt; flag when starting the container. Within the container, only the loopback device is created.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Possible Use Cases:
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;none&lt;/code&gt; network driver in Docker provides complete network isolation for containers, making it suitable for specific use cases where network connectivity is not required or should be restricted. Here are some possible scenarios where you might consider using the “none” network driver:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Highly Sensitive Applications:&lt;/strong&gt; For applications handling highly sensitive data or running critical processes, isolating them from any network connectivity using the “none” network driver adds an extra layer of security.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Isolation from Malware or Attacks:&lt;/strong&gt; In environments where there’s a higher risk of network-based attacks or malware, running containers on the &lt;code&gt;none&lt;/code&gt; network can reduce the attack surface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Debugging:&lt;/strong&gt; When debugging networking issues within a container or testing network-related functionalities, isolating the container using the &lt;code&gt;none&lt;/code&gt; network driver helps eliminate external network interference.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simulating Network Outages:&lt;/strong&gt; For testing how applications behave during network outages or when connectivity is lost, using the &lt;code&gt;none&lt;/code&gt; network driver allows you to simulate these scenarios effectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stand-Alone Containers:&lt;/strong&gt; Containers that do not require any external dependencies or network services can be run on the &lt;code&gt;none&lt;/code&gt; network to ensure they operate independently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Resource Isolation:&lt;/strong&gt; Isolating containers with resource-intensive tasks or specific workloads from the network can prevent network-related performance impacts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Transient Containers:&lt;/strong&gt; Containers that are spun up temporarily for specific tasks or short-lived processes can be attached to the &lt;code&gt;none&lt;/code&gt; network to minimize exposure and clean up automatically after use (&lt;code&gt;--rm&lt;/code&gt; flag).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;👉 Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s an example of running the &lt;code&gt;ip link show&lt;/code&gt; command inside an Alpine container that is attached to the &lt;code&gt;none&lt;/code&gt; network driver:&lt;/p&gt;

&lt;p&gt;First, start an Alpine container named &lt;code&gt;app1&lt;/code&gt; with the &lt;code&gt;none&lt;/code&gt; network driver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --name app1 --network=none alpine sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the container’s shell (&lt;code&gt;sh&lt;/code&gt;), run the &lt;code&gt;ip link show&lt;/code&gt; command to display network interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ip link show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output of &lt;code&gt;ip link show&lt;/code&gt; in an Alpine container attached to the "none" network driver will typically look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1: lo: &amp;lt;LOOPBACK,UP,LOWER_UP&amp;gt; mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0@if2: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc noqueue state UP mode DEFAULT group default 
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation of the output:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;lo:&lt;/code&gt; Loopback interface, which is always present.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;eth0@if2:&lt;/code&gt; Virtual Ethernet interface (&lt;code&gt;eth0&lt;/code&gt;) with MAC address &lt;code&gt;02:42:ac:11:00:02&lt;/code&gt; and link-netnsid 0. This is typically assigned by Docker when using the &lt;code&gt;none&lt;/code&gt; network driver.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/what-is-macvlan-network-driver-4ko6"&gt;What is Macvlan network driver?&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>learning</category>
      <category>development</category>
    </item>
    <item>
      <title>What is Macvlan network driver?</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Wed, 17 Dec 2025 09:30:43 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/what-is-macvlan-network-driver-4ko6</link>
      <guid>https://dev.to/meghasharmaaaa/what-is-macvlan-network-driver-4ko6</guid>
      <description>&lt;p&gt;&lt;code&gt;Macvlan&lt;/code&gt; network is used to connect applications directly to the physical network. By using the &lt;code&gt;macvlan&lt;/code&gt; network driver to assign a &lt;code&gt;MAC address&lt;/code&gt; to each container, also allow having full &lt;code&gt;TCP/Ip&lt;/code&gt; stack. Then, the Docker daemon routes traffic to containers by their MAC addresses. You can isolate your &lt;code&gt;macvlan&lt;/code&gt; networks using different physical network interfaces. This is used in legacy applications which require &lt;code&gt;MAC address&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2cyb1pf4s742alf6z9y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2cyb1pf4s742alf6z9y.jpg" alt=" " width="800" height="852"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Macvlan&lt;/code&gt; networking in Docker is a mode that gives each container its own MAC address, making them appear as separate physical devices on the network. This enables containers to directly communicate with external networks without going through the Docker host’s network stack. &lt;code&gt;Macvlan&lt;/code&gt; networking is beneficial for scenarios where containers require direct access to the underlying network infrastructure, such as when running network-intensive applications or services that need to expose specific ports. It provides improved network performance, isolation, and flexibility compared to bridge networking, making it suitable for applications needing container-to-network communication without network address translation (NAT) overhead.&lt;/p&gt;

&lt;p&gt;For example some applications, especially legacy applications or applications which monitor network traffic, expect to be directly connected to the physical network. In this type of situation, you can use the &lt;code&gt;macvlan&lt;/code&gt; network driver to assign a MAC address to each container's virtual network interface, making it appear to be a physical network interface directly connected to the physical network. In this case, you need to designate a physical interface on your Docker host to use for the Macvlan, as well as the subnet and gateway of the network. You can even isolate your &lt;code&gt;Macvlan&lt;/code&gt; networks using different physical network interfaces.&lt;/p&gt;
&lt;h2&gt;
  
  
  Keep the following things in mind:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You may unintentionally degrade your network due to IP address exhaustion or to &lt;code&gt;VLAN spread&lt;/code&gt;, a situation that occurs when you have an inappropriately large number of unique &lt;code&gt;MAC addresses&lt;/code&gt; in your network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your networking equipment needs to be able to handle &lt;code&gt;promiscuous mode&lt;/code&gt;, where one physical interface can be assigned multiple MAC addresses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If your application can work using a bridge (on a single Docker host) or overlay (to communicate across multiple Docker hosts), these solutions may be better in the long term.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  👉 Use case of Macvlan network:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Appliances:&lt;/strong&gt; Macvlan is commonly used when running network appliances or virtual network devices within containers. For example, you might have a containerized firewall, load balancer, or VPN server that needs to interact with the external network as if it were a physical appliance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Virtual Routers:&lt;/strong&gt; In networking setups where virtual routers are utilized for routing traffic between different networks or VLANs, Macvlan can be used to create containers that act as virtual routers. These containers can have their own MAC and IP addresses and route traffic between various network segments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Containerized Servers:&lt;/strong&gt; For applications that require direct access to network hardware or external resources, Macvlan can provide containers with dedicated MAC addresses and IP addresses on the same subnet as the host or on a separate subnet. This allows the containers to communicate directly with external servers, devices, or services without network address translation (NAT) overhead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multi-Tenant Environments:&lt;/strong&gt; In multi-tenant environments where different users or applications require separate network identities and isolation, Macvlan can be used to create individual networks for each tenant. This ensures that containers belonging to different tenants operate as independent entities on the network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing and Development:&lt;/strong&gt; Macvlan networks are also useful for testing and development environments where you want containers to behave as if they were physical machines on the network. This can be beneficial for simulating real-world network configurations and scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Media Streaming and Broadcasting:&lt;/strong&gt; Applications that involve media streaming, broadcasting, or multicast communication can benefit from Macvlan networks to ensure efficient and direct communication with network hardware and services.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The following table describes the &lt;code&gt;driver-specific&lt;/code&gt; options that you can pass to &lt;code&gt;--option&lt;/code&gt; when creating a network using the &lt;code&gt;macvlan&lt;/code&gt; driver.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;macvlan_mode:&lt;/code&gt; Sets the Macvlan mode. Can be one of: &lt;code&gt;bridge&lt;/code&gt;, &lt;code&gt;vepa&lt;/code&gt;, &lt;code&gt;passthru&lt;/code&gt;, &lt;code&gt;private&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;parent:&lt;/code&gt; Specifies the parent interface to use.&lt;/p&gt;
&lt;h2&gt;
  
  
  👉 Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Most cloud providers block &lt;code&gt;macvlan&lt;/code&gt; networking. You may need physical access to your networking equipment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;macvlan&lt;/code&gt; networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You need at least &lt;code&gt;version 3.9&lt;/code&gt; of the Linux kernel, and &lt;code&gt;version 4.0&lt;/code&gt; or higher is recommended.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The examples assume your ethernet interface is &lt;code&gt;eth0&lt;/code&gt;. If your device has a different name, use that instead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;macvlan&lt;/code&gt; driver is not supported in rootless mode.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  👉 Create a Macvlan network
&lt;/h2&gt;

&lt;p&gt;When you create a Macvlan network, it can either be in bridge mode or 802.1Q trunk bridge mode.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In bridge mode, Macvlan traffic goes through a physical device on the host.&lt;/li&gt;
&lt;li&gt;In 802.1Q trunk bridge mode, traffic goes through an 802.1Q sub-interface which Docker creates on the fly. This allows you to control routing and filtering at a more granular level.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Bridge mode example:
&lt;/h2&gt;

&lt;p&gt;In our example, we have a physical network interface &lt;code&gt;eth0&lt;/code&gt; on the &lt;code&gt;172.16.86.0/24&lt;/code&gt; network and the default gateway of &lt;code&gt;172.16.86.1&lt;/code&gt; The default gateway is the IP address of the router.&lt;/p&gt;

&lt;p&gt;Now, we will create a macvlan network called &lt;code&gt;my-macvlan-net&lt;/code&gt; with the following configuration.&lt;/p&gt;

&lt;p&gt;To create a &lt;code&gt;macvlan&lt;/code&gt; network which bridges with a given physical network interface, use &lt;code&gt;--driver macvlan&lt;/code&gt; with the &lt;code&gt;docker network create&lt;/code&gt; command. You also need to specify the &lt;code&gt;parent&lt;/code&gt;, which is the interface the traffic will physically go through on the Docker host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network create -d macvlan \
  --subnet=172.16.86.0/24 \
  --gateway=172.16.86.1 \
  -o parent=eth0 \
  my-macvlan-net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Let’s break down the components of this command:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker network create:&lt;/code&gt; This part of the command instructs Docker to create a new network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-d macvlan:&lt;/code&gt; Specifies that the network driver to be used is Macvlan.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--subnet=172.168.86.0/24:&lt;/code&gt; Defines the subnet range for the Macvlan network. You can adjust this subnet range as needed for your network configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--gateway=172.16.86.1:&lt;/code&gt; Specifies the gateway IP address for the Macvlan network. Replace &lt;code&gt;172.16.86.1&lt;/code&gt; with your desired gateway IP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-o parent=eth0:&lt;/code&gt; Indicates the parent interface (physical interface) to which the Macvlan network will be attached. Replace &lt;code&gt;eth0&lt;/code&gt; with the appropriate interface name on your host machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;my-macvlan-net:&lt;/code&gt; Assigns the name &lt;code&gt;my-macvlan-net&lt;/code&gt; to the Macvlan network. You can choose a different name if desired.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need to exclude IP addresses from being used in the &lt;code&gt;macvlan&lt;/code&gt; network, such as when a given IP address is already in use, use &lt;code&gt;--aux-addresses:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network create -d macvlan \
  --subnet=192.168.32.0/24 \
  --ip-range=192.168.32.128/25 \
  --gateway=192.168.32.254 \
  --aux-address="my-router=192.168.32.129" \
  -o parent=eth0 macnet32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To confirm that the newly added macvlan network is present, run the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run this command, Docker will display a list of networks along with their IDs, names, driver types, and other details. Look for your Macvlan network in the list to confirm its presence.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ NETWORK ID     NAME               DRIVER    SCOPE
abcdef123456   bridge             bridge    local
ghijkl789012   host               host      local
mnopqr345678   none               null      local
xyz123456789   my-macvlan-net     macvlan   local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example output:&lt;code&gt;NETWORK ID:&lt;/code&gt; Unique identifier for the network.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;NAME:&lt;/code&gt; Name of the network (&lt;code&gt;my-macvlan-net&lt;/code&gt; in this case).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DRIVER:&lt;/code&gt; Network driver used for the network (Macvlan in this case).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SCOPE:&lt;/code&gt; Indicates the scope of the network (local means it's local to the Docker host).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start an container and attach it to the &lt;code&gt;my-macvlan-net&lt;/code&gt; network. The &lt;code&gt;-dit&lt;/code&gt; flags start the container in the background but allow you to attach to it. The &lt;code&gt;--rm&lt;/code&gt; flag means the container is removed when it is stopped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run --rm -dit \
  --network my-macvlan-net \
  --name my_container \
  alpine:latest \
  ash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down this command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker run:&lt;/code&gt; This command is used to create and start a new container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-d:&lt;/code&gt; Runs the container in detached mode (background).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--network= my-macvlan-net:&lt;/code&gt; Specifies that the container should be attached to the &lt;code&gt;my-macvlan-net&lt;/code&gt; Macvlan network that you created earlier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--name my_container:&lt;/code&gt; Assigns the name &lt;code&gt;my_container&lt;/code&gt; to the Docker container. You can replace &lt;code&gt;my_container&lt;/code&gt; with your desired container name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nginx:&lt;/code&gt; Specifies the Docker image to use for the container. In this example, we're using the Nginx image. Replace &lt;code&gt;nginx&lt;/code&gt; with the image name you want to use.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The container will run in the background, and you can verify its status using &lt;code&gt;docker ps&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run &lt;code&gt;docker ps&lt;/code&gt;, Docker will display a list of all running containers along with their container IDs, names, statuses, ports, and other information. Look for your container in the list to ensure it's running and verify its network configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTAINER ID       IMAGE       COMMAND            CREATED         STATUS       PORTS      NAMES
5e3ec79625d388       nginx      "/bin/bash"       1 minute ago     Up 1 minute             my_container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the &lt;code&gt;my_container&lt;/code&gt; container and notice the &lt;code&gt;MacAddress&lt;/code&gt; key within the &lt;code&gt;Networks&lt;/code&gt; key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker container inspect my_container

...truncated...
"Networks": {
  "my-macvlan-net": {
      "IPAMConfig": null,
      "Links": null,
      "Aliases": [
          "bec64291cd4c"
      ],
      "NetworkID": "5e3ec79625d388dbcc03dcf4a6dc4548644eb99d58864cf8eee2252dcfc0cc9f",
      "EndpointID": "8caf93c862b22f379b60515975acf96f7b54b7cf0ba0fb4a33cf18ae9e5c1d89",
      "Gateway": "172.16.86.1",
      "IPAddress": "172.16.86.2",
      "IPPrefixLen": 24,
      "IPv6Gateway": "",
      "GlobalIPv6Address": "",
      "GlobalIPv6PrefixLen": 0,
      "MacAddress": "02:42:ac:10:56:02",
      "DriverOpts": null
  }
}
...truncated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check out how the container sees its own network interfaces by running a couple of &lt;code&gt;docker exec&lt;/code&gt; commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker exec my_container ip addr show eth0

9: eth0@tunl0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&amp;gt; mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:10:56:02 brd ff:ff:ff:ff:ff:ff
inet 172.16.86.2/24 brd 172.16.86.255 scope global eth0
   valid_lft forever preferred_lft forever
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker exec my_container ip route

default via 172.16.86.1 dev eth0
172.16.86.0/24 dev eth0 scope link  src 172.16.86.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stop the container (Docker removes it because of the &lt;code&gt;--rm&lt;/code&gt; flag), and remove the network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker container stop my_container

$ docker network rm my-macvlan-net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  802.1Q trunked bridge example:
&lt;/h2&gt;

&lt;p&gt;In the 802.1Q trunked bridge example, your traffic flows through a sub-interface of &lt;code&gt;eth0&lt;/code&gt; (called &lt;code&gt;eth0.10&lt;/code&gt;) and Docker routes traffic to your container using its MAC address. To network devices on your network, your container appears to be physically attached to the network.&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;macvlan&lt;/code&gt; network called &lt;code&gt;my-8021q-macvlan-net&lt;/code&gt;. Modify the &lt;code&gt;subnet&lt;/code&gt;, &lt;code&gt;gateway&lt;/code&gt;, and &lt;code&gt;parent&lt;/code&gt; values to values that make sense in your environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network create -d macvlan \
  --subnet=172.16.86.0/24 \
  --gateway=172.16.86.1 \
  -o parent=eth0.10 \
  my-8021q-macvlan-net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use &lt;code&gt;docker network ls&lt;/code&gt; and &lt;code&gt;docker network inspect my-8021q-macvlan-net&lt;/code&gt; commands to verify that the network exists, is a &lt;code&gt;macvlan network&lt;/code&gt;, and has parent &lt;code&gt;eth0.10&lt;/code&gt;. You can use &lt;code&gt;ip addr show&lt;/code&gt; on the Docker host to verify that the interface eth0.10 exists and has a separate IP address.&lt;/p&gt;

&lt;p&gt;Start an &lt;code&gt;alpine&lt;/code&gt; container and attach it to the &lt;code&gt;my-8021q-macvlan-net&lt;/code&gt; network. The &lt;code&gt;-dit&lt;/code&gt; flags start the container in the background but allow you to attach to it. The &lt;code&gt;--rm&lt;/code&gt; flag means the container is removed when it is stopped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run --rm -itd \
  --network my-8021q-macvlan-net \
  --name my-second-macvlan-alpine \
  alpine:latest \
  ash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the &lt;code&gt;my-second-macvlan-alpine&lt;/code&gt; container and notice the &lt;code&gt;Mac Address&lt;/code&gt; key within the &lt;code&gt;Networks&lt;/code&gt; key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker container inspect my-second-macvlan-alpine

...truncated...
"Networks": {
  "my-8021q-macvlan-net": {
      "IPAMConfig": null,
      "Links": null,
      "Aliases": [
          "12f5c3c9ba5c"
      ],
      "NetworkID": "c6203997842e654dd5086abb1133b7e6df627784fec063afcbee5893b2bb64db",
      "EndpointID": "aa08d9aa2353c68e8d2ae0bf0e11ed426ea31ed0dd71c868d22ed0dcf9fc8ae6",
      "Gateway": "172.16.86.1",
      "IPAddress": "172.16.86.2",
      "IPPrefixLen": 24,
      "IPv6Gateway": "",
      "GlobalIPv6Address": "",
      "GlobalIPv6PrefixLen": 0,
      "MacAddress": "02:42:ac:10:56:02",
      "DriverOpts": null
  }
}
...truncated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check out how the container sees its own network interfaces by running a couple of &lt;code&gt;docker exec&lt;/code&gt; commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker exec my-second-macvlan-alpine ip addr show eth0

11: eth0@if10: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&amp;gt; mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:10:56:02 brd ff:ff:ff:ff:ff:ff
inet 172.16.86.2/24 brd 172.16.86.255 scope global eth0
   valid_lft forever preferred_lft forever
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker exec my-second-macvlan-alpine ip route

default via 172.16.86.1 dev eth0
172.16.86.0/24 dev eth0 scope link  src 172.16.86.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stop the container (Docker removes it because of the &lt;code&gt;--rm&lt;/code&gt; flag), and remove the network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker container stop my-second-macvlan-alpine

$ docker network rm my-8021q-macvlan-net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/what-is-ipvlan-network-driver-336o"&gt;What is IPvlan network driver?&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>opensource</category>
      <category>devops</category>
      <category>development</category>
    </item>
    <item>
      <title>What is IPvlan network driver?</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Sun, 14 Dec 2025 12:19:29 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/what-is-ipvlan-network-driver-336o</link>
      <guid>https://dev.to/meghasharmaaaa/what-is-ipvlan-network-driver-336o</guid>
      <description>&lt;p&gt;The IPvlan network driver in Docker is a type of network driver that provides network isolation and allows containers to have their own MAC and IP addresses on a network. It operates at Layer 2 of the OSI model and enables containers to communicate directly with the physical network, bypassing the host’s networking stack.&lt;/p&gt;

&lt;p&gt;The IPvlan network driver in Docker provides users with extensive control over IPv4 and IPv6 addressing within containers. It allows for the creation of isolated network segments with their own MAC and IP addresses, enhancing network security and segmentation capabilities.&lt;/p&gt;

&lt;p&gt;The IPvlan driver gives users total control over both IPv4 and IPv6 addressing. The VLAN driver builds on top of that in giving operators complete control of layer 2 VLAN tagging and even IPvlan L3 routing for users interested in underlay network integration.&lt;/p&gt;

&lt;p&gt;IPvlan is a new twist on the tried and true network virtualization technique. The Linux implementations are extremely lightweight because rather than using the traditional Linux bridge for isolation, they are associated to a Linux Ethernet interface or sub-interface to enforce separation between networks and connectivity to the physical network.&lt;/p&gt;

&lt;p&gt;IPvlan offers a number of unique features and plenty of room for further innovations with the various modes. Two high level advantages of these approaches are, the positive performance implications of bypassing the Linux bridge and the simplicity of having fewer moving parts. Removing the bridge that traditionally resides in between the Docker host NIC and container interface leaves a simple setup consisting of container interfaces, attached directly to the Docker host interface. This result is easy to access for external facing services as there is no need for port mappings in these scenarios.&lt;/p&gt;

&lt;p&gt;The following table describes the driver-specific options that you can pass to &lt;code&gt;--option&lt;/code&gt; when creating a network using the &lt;code&gt;ipvlan&lt;/code&gt; driver.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ipvlan_mode:&lt;/code&gt; Sets the IPvlan operating mode. Can be one of: &lt;code&gt;l2&lt;/code&gt;, &lt;code&gt;l3&lt;/code&gt;, &lt;code&gt;l3s&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ipvlan_flag:&lt;/code&gt; Sets the IPvlan mode flag. Can be one of: &lt;code&gt;bridge&lt;/code&gt;, &lt;code&gt;private&lt;/code&gt;, &lt;code&gt;vepa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;parent:&lt;/code&gt; Specifies the parent interface to use.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉Kernel requirements:
&lt;/h2&gt;

&lt;p&gt;IPvlan Linux kernel v4.2+ (support for earlier kernels exists but is buggy). To check your current kernel version, use &lt;code&gt;uname -r&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Example:
&lt;/h2&gt;

&lt;p&gt;The driver is specified with &lt;code&gt;-d driver_name&lt;/code&gt; option. In this case &lt;code&gt;-d ipvlan&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkb7bskmdumt76f7pko2w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkb7bskmdumt76f7pko2w.png" alt=" " width="343" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The parent interface in the next example &lt;code&gt;-o parent=eth0&lt;/code&gt; is configured as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ip addr show eth0
3: eth0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 192.168.1.250/24 brd 192.168.1.255 scope global eth0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the network from the host's interface as the &lt;code&gt;--subnet&lt;/code&gt; in the &lt;code&gt;docker network create&lt;/code&gt;. The container will be attached to the same network as the host interface as set via the &lt;code&gt;-o parent=&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;Create the &lt;code&gt;IPvlan&lt;/code&gt; network and run a container attaching to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# IPvlan  (-o ipvlan_mode= Defaults to L2 mode if not specified)
docker network create -d ipvlan \
    --subnet=192.168.1.0/24 \
    --gateway=192.168.1.1 \
    -o ipvlan_mode=l2 \
    -o parent=eth0 db_net

# Start a container on the db_net network
docker run --net=db_net -it --rm alpine /bin/sh

# NOTE: the containers can NOT ping the underlying host interfaces as
# they are intentionally filtered by Linux for additional isolation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default mode for &lt;code&gt;IPvlan&lt;/code&gt; is &lt;code&gt;l2&lt;/code&gt;. If &lt;code&gt;-o ipvlan_mode=&lt;/code&gt; is left unspecified, the default mode will be used. Similarly, if the &lt;code&gt;--gateway&lt;/code&gt; is left empty, the first usable address on the network will be set as the gateway. For example, if the subnet provided in the network create is &lt;code&gt;--subnet=192.168.1.0/24&lt;/code&gt; then the gateway the container receives is &lt;code&gt;192.168.1.1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The following will create the exact same network as the network &lt;code&gt;db_net&lt;/code&gt; created earlier, with the driver defaults for &lt;code&gt;--gateway=192.168.1.1&lt;/code&gt; and &lt;code&gt;-o ipvlan_mode=l2&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# IPvlan  (-o ipvlan_mode= Defaults to L2 mode if not specified)
docker network create -d ipvlan \
    --subnet=192.168.1.0/24 \
    -o parent=eth0 db_net_ipv

# Start a container with an explicit name in daemon mode
docker run --net=db_net_ipv --name=ipv1 -itd alpine /bin/sh

# Start a second container and ping using the container name
# to see the docker included name resolution functionality
docker run --net=db_net_ipv --name=ipv2 -it --rm alpine /bin/sh
ping -c 4 ipv1

# NOTE: the containers can NOT ping the underlying host interfaces as
# they are intentionally filtered by Linux for additional isolation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The drivers also support the &lt;code&gt;--internal&lt;/code&gt; flag that will completely isolate containers on a network from any communications external to that network. Since network isolation is tightly coupled to the network's parent interface the result of leaving the &lt;code&gt;-o parent=&lt;/code&gt; option off of a &lt;code&gt;docker network create&lt;/code&gt; is the exact same as the &lt;code&gt;--internal&lt;/code&gt; option. If the parent interface is not specified or the &lt;code&gt;--internal&lt;/code&gt; flag is used, a netlink type &lt;code&gt;dummy&lt;/code&gt; parent interface is created for the user and used as the parent interface effectively isolating the network completely.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 In Other Example:
&lt;/h2&gt;

&lt;p&gt;To create an IPvlan network in Docker, you can use the &lt;code&gt;docker network create&lt;/code&gt; command with the &lt;code&gt;-d ipvlan&lt;/code&gt; option. Below is an example command to create an &lt;code&gt;IPvlan&lt;/code&gt; network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create -d ipvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=eth0 my_ipvlan_network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down the components of this command:&lt;/p&gt;

&lt;p&gt;docker network create: This part of the command instructs Docker to create a new network.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-d ipvlan:&lt;/code&gt; Specifies that the network driver to be used is IPvlan.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--subnet=192.168.1.0/24:&lt;/code&gt; Defines the subnet range for the IPvlan network. You can adjust this subnet range as needed for your network configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--gateway=192.168.1.1:&lt;/code&gt; Specifies the gateway IP address for the IPvlan network. Replace 192.168.1.1 with your desired gateway IP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-o parent=eth0:&lt;/code&gt; Indicates the parent interface (physical interface) to which the IPvlan network will be attached. Replace &lt;code&gt;eth0&lt;/code&gt;with the appropriate interface name on your host machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;my_ipvlan_network:&lt;/code&gt; Assigns the name &lt;code&gt;my_ipvlan_network&lt;/code&gt; to the IPvlan network. You can choose a different name if desired.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the above command, Docker will create an IPvlan network named &lt;code&gt;my_ipvlan_network&lt;/code&gt; with the specified subnet, gateway, and parent interface.&lt;/p&gt;

&lt;p&gt;If you want to run a container and attach it to the IPvlan network you created (&lt;code&gt;my_ipvlan_network&lt;/code&gt;), you can use the &lt;code&gt;docker run&lt;/code&gt; command with the &lt;code&gt;--network=my_ipvlan_network&lt;/code&gt; option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d --network=my_ipvlan_network --name my_container nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down the components of this command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker run:&lt;/code&gt; This part of the command instructs Docker to run a new container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-d:&lt;/code&gt; Runs the container in detached mode (background).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--network=my_ipvlan_network:&lt;/code&gt; Specifies that the container should be attached to the my_ipvlan_network IPvlan network that you created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--name my_container:&lt;/code&gt; Assigns the name &lt;code&gt;my_container&lt;/code&gt; to the Docker container. You can replace my_container with your desired container name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nginx:&lt;/code&gt; Specifies the Docker image to use for the container, in this case&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the above command, Docker will create a new container named &lt;code&gt;my_container&lt;/code&gt; and attach it to the &lt;code&gt;my_ipvlan_network IPvlan&lt;/code&gt; network.&lt;/p&gt;

&lt;p&gt;To verify that the container is running and attached to the IPvlan network, you can use the &lt;code&gt;docker ps&lt;/code&gt; command to check the container's status and the network it's connected to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you should see it listed in the output of &lt;code&gt;docker ps&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTAINER ID   IMAGE    COMMAND                  CREATED          STATUS         PORTS     NAMES
123456789abc   nginx    "nginx -g 'daemon of…"   1 minute ago    Up 1 minute             my_container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/what-is-host-network-driver-4a5h"&gt;What is Host network driver?&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>learning</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What is Host network driver?</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Wed, 10 Dec 2025 11:54:36 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/what-is-host-network-driver-4a5h</link>
      <guid>https://dev.to/meghasharmaaaa/what-is-host-network-driver-4a5h</guid>
      <description>&lt;p&gt;The Host network driver in Docker is a networking mode that allows containers to directly use the networking stack of the Docker host machine. When a container is run with the Host network driver, it bypasses Docker’s network abstraction layer and gains direct access to the host’s network interfaces, routing table, and ports. This means that the container shares the same network namespace as the host, using the host’s IP address and network configuration.&lt;/p&gt;

&lt;p&gt;If you use the &lt;code&gt;host&lt;/code&gt; network mode for a container, that container's network stack isn't isolated from the Docker host (the container shares the host's networking namespace), and the container doesn't get its own IP-address allocated. For instance, if you run a container which binds to port 80 and you use host networking, the container's application is available on port &lt;code&gt;80&lt;/code&gt; on the &lt;code&gt;host&lt;/code&gt;'s IP address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use cases:
&lt;/h2&gt;

&lt;p&gt;Host mode networking in Docker can be beneficial for several use cases where direct access to the host’s networking stack is required. Here are some scenarios where host mode networking can be useful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;High-Performance Applications:&lt;/strong&gt; Host mode networking is ideal for applications that demand maximum network performance and low latency. By bypassing Docker’s networking abstraction layer, containers can achieve better throughput and reduced overhead, making it suitable for high-performance workloads such as databases or real-time streaming services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Networking Tools and Utilities:&lt;/strong&gt; Networking tools or utilities that require direct access to network interfaces or network configuration on the host machine can benefit from host mode networking. This includes tools like network monitoring agents, packet sniffers, or VPN clients that need full access to the host’s network stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Legacy Applications:&lt;/strong&gt; Legacy applications that are designed to run directly on the host and expect to bind to specific host ports can be containerized using host mode networking. This allows the containerized application to behave similarly to how it would run natively on the host without network address translation (NAT) or port mapping.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single-Container Deployment:&lt;/strong&gt; In cases where a single container needs to expose multiple services on different ports without conflicts, host mode networking can simplify the configuration. Each service within the container can bind directly to the corresponding port on the host, avoiding port collision issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Troubleshooting and Debugging:&lt;/strong&gt; During network troubleshooting or debugging tasks, using host mode networking can provide a clear view of network traffic and behavior by directly accessing host interfaces and routing tables. This can be useful for diagnosing network-related issues within containers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Containerized Network Services:&lt;/strong&gt; Certain network services or daemons running inside containers may require access to low-level network functionalities that are only available in the host’s networking stack. Host mode networking allows these services to operate with full network capabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integration with Host Services:&lt;/strong&gt; Applications that need seamless integration with host services or rely on specific network configurations present on the host machine can benefit from host mode networking. This ensures compatibility and consistent behavior between containerized services and host-level networking setups.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Limitations of the &lt;code&gt;host&lt;/code&gt; driver
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lack of Network Isolation:&lt;/strong&gt; Containers using the Host network driver share the same networking namespace as the host machine, leading to reduced network isolation. This means that processes running inside the container have full access to the host’s network interfaces, potentially increasing security risks if not properly configured.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Port Binding Conflicts:&lt;/strong&gt; Since containers using the Host network driver share the same network stack as the host, conflicts can occur if multiple containers attempt to bind to the same ports on the host. This can lead to port binding errors and service disruption.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security Concerns:&lt;/strong&gt; Host mode networking reduces network isolation between containers and the host, which can pose security risks, especially in multi-tenant environments. Containers running in Host mode have direct access to host network interfaces and services, potentially exposing sensitive information or resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Limited Scalability:&lt;/strong&gt; Host mode networking may not scale well in environments with a large number of containers or distributed systems. It may not be suitable for complex networking architectures or deployments requiring advanced network routing and segmentation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Only works on Linux machines:&lt;/strong&gt; The Host network driver in Docker only works on Linux machines. This limitation arises due to the way the Host networking mode is implemented and how it leverages the underlying networking capabilities of the Linux kernel.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example using &lt;code&gt;host&lt;/code&gt; driver:
&lt;/h2&gt;

&lt;p&gt;To use the Host network driver in Docker, you can specify the &lt;code&gt;--network=host&lt;/code&gt; option when running a container. This option tells Docker to use the host's networking stack directly for the container, allowing the container to share the same network namespace as the host machine. Here's how you can use the Host network driver:&lt;/p&gt;

&lt;p&gt;For example, To run an Nginx container named &lt;code&gt;app2&lt;/code&gt; using the Host network driver in Docker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d --network=host --name app2 nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Let’s break down the command:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker run:&lt;/code&gt; This is the command to run a new Docker container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-d:&lt;/code&gt; This flag runs the container in detached mode, meaning it runs in the background.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--network=host:&lt;/code&gt; This option specifies that the container should use the host's networking stack directly, using the Host network driver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--name app2:&lt;/code&gt; This option gives the container the name "app2" so that you can refer to it easily.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nginx:&lt;/code&gt; This is the name of the Docker image to use for the container. In this case, we're using the Nginx official image.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running this command, Docker will start a new Nginx container named “app2” using the Host network driver.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;docker inspect&lt;/code&gt; command to view detailed information about the container, including its network settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker inspect app2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s an example of what the output might look like for a container named &lt;code&gt;app2&lt;/code&gt; running with the Host network driver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {
        "Id": "container_id",
        "Created": "2024-03-25T12:34:56.000Z",
        "State": {
            ...
        },
        "NetworkSettings": {
            "Networks": {
                "host": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            },
            ...
        },
        ...
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check the logs of the &lt;code&gt;app2&lt;/code&gt; container, you would use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs app2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To clean up and remove the Docker containers that were created during the hands-on lab, you can use the &lt;code&gt;docker rm&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rm -f app2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command removes the containers named &lt;code&gt;app2&lt;/code&gt;. The &lt;code&gt;-f&lt;/code&gt; flag is used to force the removal of the containers even if they are currently running.&lt;/p&gt;

&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/what-is-overlay-network-driver-1l88"&gt;What is Overlay network driver?&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>opensource</category>
      <category>learning</category>
    </item>
    <item>
      <title>What is Overlay network driver?</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Fri, 05 Dec 2025 11:48:22 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/what-is-overlay-network-driver-1l88</link>
      <guid>https://dev.to/meghasharmaaaa/what-is-overlay-network-driver-1l88</guid>
      <description>&lt;p&gt;The &lt;code&gt;overlay&lt;/code&gt; network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it to communicate securely when encryption is enabled. Docker transparently handles routing of each packet to and from the correct Docker daemon host and the correct destination container.&lt;/p&gt;

&lt;p&gt;You can create user-defined &lt;code&gt;overlay&lt;/code&gt; networks using &lt;code&gt;docker network create&lt;/code&gt;, in the same way that you can create user-defined &lt;code&gt;bridge&lt;/code&gt; networks. Services or containers can be connected to more than one network at a time. Services or containers can only communicate across networks they're each connected to.&lt;/p&gt;

&lt;p&gt;Overlay networks are often used to create a connection between Swarm services, but you can also use it to connect standalone containers running on different hosts. When using standalone containers, it’s still required that you use Swarm mode to establish a connection between the hosts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an overlay network
&lt;/h2&gt;

&lt;p&gt;Before you start, you must ensure that participating nodes can communicate over the network. The following lists ports that need to be open to each host participating in an overlay network:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ports:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2377/tcp:&lt;/code&gt; The default Swarm control plane port, is configurable with &lt;code&gt;docker swarm join --listen-addr&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;4789/udp:&lt;/code&gt; The default overlay traffic port, configurable with &lt;code&gt;docker swarm init --data-path-addr&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;7946/tcp&lt;/code&gt;, &lt;code&gt;7946/udp:&lt;/code&gt; Used for communication among nodes, not configurable&lt;/p&gt;

&lt;h2&gt;
  
  
  Here are the steps to create an overlay network in Docker Swarm:
&lt;/h2&gt;

&lt;p&gt;👉 &lt;strong&gt;Initialize Docker Swarm :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker swarm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command initializes Docker Swarm on the host and creates a Swarm manager node.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Create an Overlay Network:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once Docker Swarm is initialized, you can create an overlay network using the &lt;code&gt;docker network create&lt;/code&gt; command with the &lt;code&gt;--driver&lt;/code&gt; option set to &lt;code&gt;overlay&lt;/code&gt;. Optionally, you can specify additional parameters such as subnet, gateway, and network name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create --driver overlay my-overlay-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also specify subnet and gateway parameters while creating the overlay network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create --driver overlay --subnet=10.0.1.0/24 --gateway=10.0.1.1 my-overlay-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You Can also use &lt;code&gt;— attachable&lt;/code&gt; Command&lt;/p&gt;

&lt;p&gt;To create an overlay network that containers on other Docker hosts can connect to, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create --driver overlay --attachable my-overlay-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--attachable&lt;/code&gt; option enables both standalone containers and Swarm services to connect to the overlay network. Without &lt;code&gt;--attachable&lt;/code&gt;, only Swarm services can connect to the network.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Verify the Overlay Network:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After creating the overlay network, you can use the docker network ls command to list all networks and verify that your overlay network has been created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Encrypt traffic on an overlay network
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;--opt encrypted&lt;/code&gt; flag to encrypt the application data transmitted over the overlay network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create \
  --opt encrypted \
  --driver overlay \
  --attachable \
  my-attachable-multi-host-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enables IPsec encryption at the level of the Virtual Extensible LAN (VXLAN). This encryption imposes a non-negligible performance penalty, so you should test this option before using it in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attach a container to an overlay network
&lt;/h2&gt;

&lt;p&gt;Adding containers to an overlay network gives them the ability to communicate with other containers without having to set up routing on the individual Docker daemon hosts. A prerequisite for doing this is that the hosts have joined the same Swarm.&lt;/p&gt;

&lt;p&gt;To join an overlay network named &lt;code&gt;multi-host-network&lt;/code&gt; with a &lt;code&gt;busybox&lt;/code&gt; container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run --network multi-host-network busybox sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Due to limitations set by the Linux kernel, overlay networks become unstable and inter-container communications may break when 1000 containers are co-located on the same host.&lt;/p&gt;

&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/bridge-network-driver-3co6"&gt;What is Bridge network driver?&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;br&gt;
Hashnode: &lt;a href="https://meghasharma.hashnode.dev/" rel="noopener noreferrer"&gt;Megha Sharma's Blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
    <item>
      <title>What is Bridge network driver?</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Mon, 01 Dec 2025 09:36:52 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/bridge-network-driver-3co6</link>
      <guid>https://dev.to/meghasharmaaaa/bridge-network-driver-3co6</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh7kjbqo9oh9km9z6lag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh7kjbqo9oh9km9z6lag.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bridge network is a default network created automatically when you deploy a container. Bridge network uses a software bridge that allows containers connected to the same bridge network to communicate. Bridge networks used on containers that are running on the same Docker daemon host. The bridge network creates a private internal isolated network to the host so containers on this network can communicate.&lt;/p&gt;

&lt;p&gt;In terms of networking, a bridge network is a Link Layer device which forwards traffic between network segments. A bridge can be a hardware device or a software device running within a host machine’s kernel.&lt;/p&gt;

&lt;p&gt;In terms of Docker, a bridge network uses a software bridge which lets containers connected to the same bridge network communicate, while providing isolation from containers that aren’t connected to that bridge network. The Docker bridge driver automatically installs rules in the host machine so that containers on different bridge networks can’t communicate directly with each other.&lt;/p&gt;

&lt;p&gt;When you start Docker, a default bridge network (also called &lt;code&gt;bridge&lt;/code&gt;) is created automatically, and newly-started containers connect to it unless otherwise specified. You can also create user-defined custom bridge networks. User-defined bridge networks are superior to the default &lt;code&gt;bridge&lt;/code&gt; network.&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Differences between user-defined bridges and the default bridge
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;User-defined bridges provide automatic DNS resolution between containers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Containers on the default bridge network can only access each other by IP addresses, unless you use the &lt;code&gt;--link&lt;/code&gt; option, which is considered legacy. On a user-defined &lt;code&gt;bridge&lt;/code&gt; network, containers can resolve each other by name or alias. Imagine an application with a web front-end and a database back-end. If you call your containers &lt;code&gt;web&lt;/code&gt; and &lt;code&gt;db&lt;/code&gt;, the web container can connect to the &lt;code&gt;db&lt;/code&gt; container at &lt;code&gt;db&lt;/code&gt;, no matter which Docker host the application stack is running on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you run the same application stack on the default bridge network, you need to manually create links between the containers (using the legacy &lt;code&gt;--link&lt;/code&gt; flag). These links need to be created in both directions, so you can see this gets complex with more than two containers which need to communicate. Alternatively, you can manipulate the &lt;code&gt;/etc/hosts&lt;/code&gt; files within the containers, but this creates problems that are difficult to debug.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;User-defined bridges provide better isolation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;All containers without a &lt;code&gt;--network&lt;/code&gt; specified, are attached to the default bridge network. This can be a risk, as unrelated stacks/services/containers are then able to communicate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using a user-defined network provides a scoped network in which only containers attached to that network are able to communicate.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Containers can be attached and detached from user-defined networks on the fly:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;During a container’s lifetime, you can connect or disconnect it from user-defined networks on the fly. To remove a container from the default bridge network, you need to stop the container and recreate it with different network options.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Each user-defined network creates a configurable bridge:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If your containers use the default bridge network, you can configure it, but all the containers use the same settings, such as MTU and &lt;code&gt;iptables&lt;/code&gt; rules. In addition, configuring the default bridge network happens outside of Docker itself, and requires a restart of Docker.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User-defined bridge networks are created and configured using &lt;code&gt;docker network create&lt;/code&gt;. If different groups of applications have different network requirements, you can configure each user-defined bridge separately, as you create it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Linked containers on the default bridge network share environment variables:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Originally, the only way to share environment variables between two containers was to link them using the &lt;code&gt;--link&lt;/code&gt; flag. This type of variable sharing isn't possible with user-defined networks. However, there are superior ways to share environment variables.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple containers can mount a file or directory containing the shared information, using a Docker volume.&lt;/li&gt;
&lt;li&gt;Multiple containers can be started together using &lt;code&gt;docker-compose&lt;/code&gt; and the compose file can define the shared variables.&lt;/li&gt;
&lt;li&gt;You can use swarm services instead of standalone containers, and take advantage of shared secrets and configs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👉 Manage a user-defined bridge
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;docker network create&lt;/code&gt; command to create a user-defined bridge network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network create my-net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👉 Connect a container to a user-defined bridge
&lt;/h2&gt;

&lt;p&gt;When you create a new container, you can specify one or more &lt;code&gt;--network&lt;/code&gt; flags. This example connects an Nginx container to the &lt;code&gt;my-net&lt;/code&gt; network. It also publishes port 80 in the container to port 8080 on the Docker host, so external clients can access that port. Any other container connected to the &lt;code&gt;my-net&lt;/code&gt; network has access to all ports on the &lt;code&gt;my-nginx&lt;/code&gt; container, and vice versa.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker create --name my-nginx \
  --network my-net \
  --publish 8080:80 \
  nginx:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To connect a running container to an existing user-defined bridge, use the &lt;code&gt;docker network connect&lt;/code&gt; command. The following command connects an already-running &lt;code&gt;my-nginx&lt;/code&gt; container to an already-existing &lt;code&gt;my-net&lt;/code&gt; network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network connect my-net my-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👉 Disconnect a container from a user-defined bridge
&lt;/h2&gt;

&lt;p&gt;To disconnect a running container from a user-defined bridge, use the &lt;code&gt;docker network disconnect&lt;/code&gt; command. The following command disconnects the &lt;code&gt;my-nginx&lt;/code&gt; container from the &lt;code&gt;my-net&lt;/code&gt; network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network disconnect my-net my-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/user-defined-networks-1icj"&gt;User-defined networks&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;br&gt;
Hashnode: &lt;a href="https://meghasharma.hashnode.dev/" rel="noopener noreferrer"&gt;Megha Sharma's Blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>opensource</category>
      <category>docker</category>
      <category>cloud</category>
    </item>
    <item>
      <title>User-defined networks</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Fri, 28 Nov 2025 16:56:15 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/user-defined-networks-1icj</link>
      <guid>https://dev.to/meghasharmaaaa/user-defined-networks-1icj</guid>
      <description>&lt;p&gt;You can create custom, user-defined networks, and connect multiple containers to the same network. Once connected to a user-defined network, containers can communicate with each other using container IP addresses or container names.&lt;/p&gt;

&lt;p&gt;The following example creates a network using the &lt;code&gt;bridge&lt;/code&gt; network driver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker network create -d bridge my-net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running a container in the created network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run --network=my-net -itd --name=container3 busybox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;strong&gt;Container networks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In addition to user-defined networks, you can attach a container to another container’s networking stack directly, using the &lt;code&gt;--network container:&amp;lt;name|id&amp;gt;&lt;/code&gt; flag format.&lt;/p&gt;

&lt;p&gt;The following flags aren’t supported for containers using the container: networking mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--add-host&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--hostname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--dns&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--dns-search&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--dns-option&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--mac-address&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--publish&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--publish-all&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--expose&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;Published ports&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, when you create or run a container using &lt;code&gt;docker create&lt;/code&gt; or &lt;code&gt;docker run&lt;/code&gt;, the container doesn't expose any of its ports to the outside world. Use the &lt;code&gt;--publish&lt;/code&gt; or &lt;code&gt;-p&lt;/code&gt; flag to make a port available to services outside of Docker. This creates a firewall rule in the host, mapping a container port to a port on the Docker host to the outside world. Here are some examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flag value:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p 8080:80:&lt;/code&gt; Map port &lt;code&gt;8080&lt;/code&gt; on the Docker host to TCP port &lt;code&gt;80&lt;/code&gt; in the container.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p 192.168.1.100:8080:80:&lt;/code&gt; Map port &lt;code&gt;8080&lt;/code&gt; on the Docker host IP &lt;code&gt;192.168.1.100&lt;/code&gt; to TCP port &lt;code&gt;80&lt;/code&gt; in the container.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p 8080:80/udp:&lt;/code&gt; Map port &lt;code&gt;8080&lt;/code&gt; on the Docker host to UDP port &lt;code&gt;80&lt;/code&gt; in the container.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p 8080:80/tcp -p 8080:80/udp:&lt;/code&gt; Map TCP port &lt;code&gt;8080&lt;/code&gt; on the Docker host to TCP port &lt;code&gt;80&lt;/code&gt; in the container, and map UDP port &lt;code&gt;8080&lt;/code&gt; on the Docker host to UDP port &lt;code&gt;80&lt;/code&gt; in the container&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;IP address and hostname&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, the container gets an IP address for every Docker network it attaches to. A container receives an IP address out of the IP subnet of the network. The Docker daemon performs dynamic subnetting and IP address allocation for containers. Each network also has a default subnet mask and gateway.&lt;/p&gt;

&lt;p&gt;You can connect a running container to multiple networks, either by passing the &lt;code&gt;--network&lt;/code&gt; flag multiple times when creating the container, or using the &lt;code&gt;docker network connect&lt;/code&gt; command for already running containers. In both cases, you can use the &lt;code&gt;--ip&lt;/code&gt; or &lt;code&gt;--ip6&lt;/code&gt; flags to specify the container's IP address on that particular network.&lt;/p&gt;

&lt;p&gt;In the same way, a container’s hostname defaults to be the container’s ID in Docker. You can override the hostname using &lt;code&gt;--hostname&lt;/code&gt;. When connecting to an existing network using &lt;code&gt;docker network connect&lt;/code&gt;, you can use the &lt;code&gt;--alias&lt;/code&gt; flag to specify an additional network alias for the container on that network.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;DNS services&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Containers use the same DNS servers as the host by default, but you can override this with &lt;code&gt;--dns&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By default, containers inherit the DNS settings as defined in the &lt;code&gt;/etc/resolv.conf&lt;/code&gt; configuration file. Containers that attach to the default &lt;code&gt;bridge&lt;/code&gt; network receive a copy of this file. Containers that attach to a custom network use Docker's embedded DNS server. The embedded DNS server forwards external DNS lookups to the DNS servers configured on the host.&lt;/p&gt;

&lt;p&gt;You can configure DNS resolution on a per-container basis, using flags for the &lt;code&gt;docker run&lt;/code&gt; or &lt;code&gt;docker create&lt;/code&gt; command used to start the container. The following table describes the available &lt;code&gt;docker run&lt;/code&gt; flags related to DNS configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flag:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--dns:&lt;/code&gt; The IP address of a DNS server. To specify multiple DNS servers, use multiple &lt;code&gt;--dns&lt;/code&gt; flags. If the container can't reach any of the IP addresses you specify, it uses Google's public DNS server at &lt;code&gt;8.8.8.8&lt;/code&gt;. This allows containers to resolve internet domains.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--dns-search:&lt;/code&gt; A DNS search domain to search non-fully qualified hostnames. To specify multiple DNS search prefixes, use multiple -&lt;code&gt;-dns-search&lt;/code&gt; flags.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--dns-opt:&lt;/code&gt; A key-value pair representing a DNS option and its value. See your operating system's documentation for &lt;code&gt;resolv.conf&lt;/code&gt; for valid options.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--hostname:&lt;/code&gt; The hostname a container uses for itself. Defaults to the container’s ID if not specified.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Custom hosts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your container will have lines in &lt;code&gt;/etc/hosts&lt;/code&gt; which define the hostname of the container itself, as well as &lt;code&gt;localhost&lt;/code&gt; and a few other common things. Custom hosts, defined in &lt;code&gt;/etc/hosts&lt;/code&gt; on the host machine, aren't inherited by containers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="https://buymeacoffee.com/meghasharma" rel="noopener noreferrer"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;br&gt;
🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/docker-networking-overview-12gn"&gt;Docker Networking Overview&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://meghasharmaa704.medium.com/" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;br&gt;
Hashnode: &lt;a href="https://meghasharma.hashnode.dev/" rel="noopener noreferrer"&gt;Megha Sharma's Blog&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>cloud</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Docker Networking Overview</title>
      <dc:creator>Megha Sharma</dc:creator>
      <pubDate>Fri, 21 Nov 2025 11:37:25 +0000</pubDate>
      <link>https://dev.to/meghasharmaaaa/docker-networking-overview-12gn</link>
      <guid>https://dev.to/meghasharmaaaa/docker-networking-overview-12gn</guid>
      <description>&lt;p&gt;Docker networking refers to the set of technologies and functionalities within Docker that enable communication between containers, between containers and the host machine, and between containers and external networks. It allows containers to interact with each other and with external systems securely and efficiently.&lt;/p&gt;

&lt;p&gt;Container networking refers to the ability for containers to connect to and communicate with each other, or to non-Docker workloads.&lt;/p&gt;

&lt;p&gt;Containers have networking enabled by default, and they can make outgoing connections. A container has no information about what kind of network it’s attached to, or whether their peers are also Docker workloads or not. A container only sees a network interface with an IP address, a gateway, a routing table, DNS services, and other networking details. That is, unless the container uses the &lt;code&gt;none&lt;/code&gt; network driver.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Here are the key points to understand about Docker networking:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Container Communication:&lt;/strong&gt; Docker networking enables containers running on the same host to communicate with each other using &lt;code&gt;IP addresses&lt;/code&gt; or &lt;code&gt;DNS&lt;/code&gt; names. This communication can be established within a single Docker host or across multiple Docker hosts in a cluster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Isolation:&lt;/strong&gt; Docker networking provides network isolation between containers, ensuring that each container has its own network stack and IP address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Default Bridge Network:&lt;/strong&gt; When you install Docker, it automatically creates a default &lt;code&gt;bridge network&lt;/code&gt; called &lt;code&gt;bridge&lt;/code&gt;. Containers connected to this network can communicate with each other using container names as &lt;code&gt;DNS&lt;/code&gt; names. The default bridge network is suitable for most development and testing scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Custom Networks:&lt;/strong&gt; Docker allows users to create custom networks using the &lt;code&gt;docker network create&lt;/code&gt; command. This feature enables better control over networking configurations such as IP address ranges, subnets, and DNS settings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Networking Drivers:&lt;/strong&gt; Docker supports different networking drivers such as &lt;code&gt;bridge&lt;/code&gt;, &lt;code&gt;host&lt;/code&gt;, &lt;code&gt;overlay&lt;/code&gt;, &lt;code&gt;macvlan&lt;/code&gt;, and &lt;code&gt;none&lt;/code&gt;. Each driver has specific use cases and functionalities, providing flexibility in how containers interact with networks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Container-to-Container Communication:&lt;/strong&gt; Containers within the same network can communicate with each other using their container names as &lt;code&gt;hostnames&lt;/code&gt;. Docker’s built-in DNS server resolves container names to their respective IP addresses within the network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Container-to-External Network Communication:&lt;/strong&gt; Docker containers can communicate with external networks and services through port mappings or by connecting containers to external networks using custom &lt;code&gt;bridge&lt;/code&gt; networks or &lt;code&gt;host&lt;/code&gt; networking mode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Service Discovery and Load Balancing:&lt;/strong&gt; Docker networking integrates with service discovery and load balancing mechanisms, such as Docker Swarm’s built-in DNS-based service discovery and load balancing features. This allows containers to discover and communicate with services running on different containers or nodes in a cluster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Security:&lt;/strong&gt; Docker networking provides security features such as network segmentation, firewall rules, and network policies to control inbound and outbound traffic, ensuring secure communication between containers and networks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability and Orchestration:&lt;/strong&gt; Docker networking is scalable and integrates seamlessly with container orchestration platforms like Docker Swarm and Kubernetes, allowing for dynamic network configurations and efficient management of containerized applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;👉 &lt;strong&gt;Types of networking in Docker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bridge Network:&lt;/strong&gt;&lt;br&gt;
Bridge network is a default network created automatically when you deploy a container. Bridge network uses a software bridge that allows containers connected to the same bridge network to communicate. Bridge networks used on containers that are running on the same &lt;code&gt;Docker daemon host&lt;/code&gt;. The bridge network creates a private internal isolated network to the host so containers on this network can communicate.&lt;/p&gt;

&lt;p&gt;The Bridge Network in Docker is a default networking mode that enables communication between containers on the same Docker host. It provides network isolation, giving each container its own IP address and DNS configuration. Containers connected to the bridge network can communicate using their IP addresses or container names, facilitated by Docker’s built-in DNS server. Additionally, bridge networking allows containers to access the internet through NAT rules. It’s commonly used in development and testing environments for local container communication. However, for more complex networking needs or distributed systems across multiple hosts, other Docker networking modes may be preferred.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vy4w5zxv1c2lv13xl4b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vy4w5zxv1c2lv13xl4b.png" alt=" " width="800" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Host Network:&lt;/strong&gt;&lt;br&gt;
The Host Network mode in Docker allows containers to share the host’s networking stack directly, bypassing Docker’s network isolation. In this mode, containers use the host’s IP address, network interfaces, and routing table, resulting in improved networking performance. Containers on the host network can access external networks and services without the overhead of network address translation (NAT) or port mapping. However, this mode lacks network isolation between containers and may not be suitable for scenarios requiring strict network segmentation. Host networking is commonly used for applications requiring maximum network performance or direct access to host networking interfaces, such as network-intensive services or legacy applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9u44xw3qs02xpszquhuv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9u44xw3qs02xpszquhuv.png" alt=" " width="771" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overlay Network:&lt;/strong&gt;&lt;br&gt;
Overlay networking is used if container on node A wants to talk to node B then to make communication between them we use Overlay networking. Overlay networking uses &lt;code&gt;VXLAN to create an Overlay network&lt;/code&gt;. This has the advantage of providing maximum portability across various cloud and on-premises networks. By default, the Overlay network is encrypted with the &lt;code&gt;AES algorithm&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Overlay networking in Docker, especially in Docker Swarm, is used to facilitate communication between containers across different Docker hosts or nodes within a Swarm cluster. When a container on one node (let’s say node A) needs to communicate with a container on another node (node B), overlay networking comes into play.&lt;/p&gt;

&lt;p&gt;Overlay networking leverages technologies like &lt;code&gt;VXLAN&lt;/code&gt; (&lt;code&gt;Virtual Extensible LAN&lt;/code&gt;) to create a virtual network overlay that spans all nodes in the Swarm cluster. This overlay network enables seamless communication between containers regardless of their physical host, providing a unified network environment for distributed applications.&lt;/p&gt;

&lt;p&gt;One of the key advantages of overlay networking is its portability across various cloud environments and on-premises networks. Containers can communicate across different infrastructure setups without needing to worry about underlying network configurations, thanks to the abstraction provided by overlay networking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1zm9um19ic7pvr4ce9w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1zm9um19ic7pvr4ce9w.jpg" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Macvlan Network:&lt;/strong&gt;&lt;br&gt;
Macvlan network is used to connect applications directly to the physical network. By using the macvlan network driver to &lt;code&gt;assign a MAC address&lt;/code&gt; to each container, also allow having full TCP/Ip stack. Then, the &lt;code&gt;Docker daemon routes traffic&lt;/code&gt; to containers by their MAC addresses. You can isolate your macvlan networks using different physical network interfaces. This is used in legacy applications which require MAC address.&lt;/p&gt;

&lt;p&gt;Macvlan networking in Docker is a mode that gives each container its own MAC address, making them appear as separate physical devices on the network. This enables containers to directly communicate with external networks without going through the Docker host’s network stack. Macvlan networking is beneficial for scenarios where containers require direct access to the underlying network infrastructure, such as when running network-intensive applications or services that need to expose specific ports. It provides improved network performance, isolation, and flexibility compared to bridge networking, making it suitable for applications needing container-to-network communication without network address translation (NAT) overhead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqpkqvll5xa64ufpax9bk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqpkqvll5xa64ufpax9bk.png" alt=" " width="800" height="813"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ipvlan:&lt;/strong&gt;&lt;br&gt;
IPvlan networks give users total control over both IPv4 and IPv6 addressing. The VLAN driver builds on top of that in giving operators complete control of layer 2 VLAN tagging and even IPvlan L3 routing for users interested in underlay network integration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fonu5m3eaum1d8wt5bied.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fonu5m3eaum1d8wt5bied.png" alt=" " width="343" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📝 Liked this blog?&lt;br&gt;
If you found this helpful, &lt;a href="//buymeacoffee.com/meghasharma"&gt;Buy me a coffee&lt;/a&gt; ☕&lt;br&gt;
💬 Have questions or thoughts on Docker? Leave a comment below!&lt;br&gt;
👉 Want more Docker content? Follow me on Dev&lt;/p&gt;

&lt;p&gt;🔗 Explore More Docker Tutorials&lt;br&gt;
Next Blog: &lt;a href="https://dev.to/meghasharmaaaa/docker-storage-drivers-4a75"&gt;Docker storage drivers&lt;/a&gt;&lt;br&gt;
Medium Profile: &lt;a href="https://medium.com/@meghasharmaa704" rel="noopener noreferrer"&gt;Meghasharmaa&lt;/a&gt;&lt;br&gt;
Hashnode: &lt;a href="https://meghasharma.hashnode.dev/" rel="noopener noreferrer"&gt;Megha Sharma's Blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>cloud</category>
      <category>devops</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
