Skip to content

Instantly share code, notes, and snippets.

@bbl
Last active April 15, 2021 10:35
Show Gist options
  • Save bbl/dad5ea94cdf8f384bb7a47dd4869b2eb to your computer and use it in GitHub Desktop.
Save bbl/dad5ea94cdf8f384bb7a47dd4869b2eb to your computer and use it in GitHub Desktop.

Actually, it's a guide to setup docker macvlan network and it can be used to attach static ip to container on public/local network.

  1. Create docker public network:
docker network create -d macvlan --subnet=$SUBNET --gateway=$GATEWAY_IP -o parent=eth0 public

Where:
$SUBNET - your public network subnet
$GATEWAY_IP - your public network gateway
parent=eth0 - interface on machine which belongs to this public network

  1. Run/create container :
docker run -dti --net public --ip $PUBLIC_IP --mac-address $MAC_ADDR ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment