Skip to content

Instantly share code, notes, and snippets.

@catataw
Forked from eerotal/docker_swarm_macvlan.txt
Created September 23, 2023 01:38
Show Gist options
  • Select an option

  • Save catataw/edf134ab235bff6e9a16a176aa77e875 to your computer and use it in GitHub Desktop.

Select an option

Save catataw/edf134ab235bff6e9a16a176aa77e875 to your computer and use it in GitHub Desktop.
Docker Swarm service with a macvlan network
# Set network interfaces on all worker nodes to promiscuous mode.
# Run on all worker nodes:
ip link set <bridged interface> promisc on
# Create a config-only network for each worker node.
# This defines the host-specific network configurations.
# Run on all worker nodes:
docker network create \
--config-only \
-d macvlan \
--subnet 192.168.0.0/24 \
--gateway 192.168.0.1 \
-o parent=<bridged interface> \
macvlan-cfg
# Create the macvlan network in the Swarm cluster.
# Run on manager node:
docker network create \
--scope swarm \
--config-from macvlan-cfg \
-d macvlan \
macvlan
# Start a service attached to the macvlan network.
docker service create \
--replicas 1 \
--network macvlan \
nginx
Resources:
- https://collabnix.com/docker-17-06-swarm-mode-now-with-macvlan-support/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment