2022-10-06 00:18:10 +01:00
.
2022-10-06 00:18:10 +01:00
2022-09-21 03:06:42 +01:00
2022-09-25 10:15:43 +01:00

docker

[TOC]

Volumes

NFS

Notes:

docker-compose.yaml

volumes:
  volume00:
    driver: local
    driver_opts:
      type: ${VOLUME_TYPE}
      o: ${VOLUME_O}
      device: "${VOLUME_DEVICE}"

.env

VOLUME_TYPE="nfs"

# DNS server ip, RW:read and write
VOLUME_O="addr=10.10.1.1,rw" 

# Folder on NFS Server
## Must exists on nfs server, or security errors when starting container 
VOLUME_DEVICE=":/export/docker-volumes/volume00" 

Network

Macvlan

Create

How to create a docker macvlan network

# run on host
docker network create -d macvlan --subnet=192.168.1.249/24 --gateway=192.168.1.1  -o parent=eth0 macvlan_network

Host comunication

if network required between host and docker container on a macvlan docker network

  • Option 1 - Create another macvlan on host

    • Setup vars

      MACVLAN_NAME=macvlan_bridge
      HOST_ETHERNET_ADP=eth0
      NETWORK=192.168.1.0/24
      
    • Create mavclan adapter

      ip link add $MACVLAN_NAME link $HOST_ETHERNET_ADP type macvlan mode bridge  
      ip addr add $NETWORK dev $MACVLAN_NAME  
      ifconfig $MACVLAN_NAME up  
      
    • Add routing

      ip route add $CONTAINER_MAVLAN_IP dev $MACVLAN_NAME
      
    • Delete mavclan adapter

      ifconfig $MACVLAN_NAME down
      ip link del $MACVLAN_NAME 
      
    • Persisting macvlan configuration Example:

      • network: 192.168.1.0/24
      • macvlan name:: macvlan_bridge
      • macvlan static ip: 192.168.1.240/32
      • docker containers on macvlan networks:
        • 192.168.1.254
        • 192.168.1.253
        • 192.168.1.250
        • 192.168.1.248
      # create/edit /etc/network/interfaces.d/macvlan_bridge
      iface macvlan_bridge inet manual
          pre-up ip link add macvlan_bridge link eth0 type macvlan mode bridge
          pre-up ip addr add 192.168.1.240/32 dev macvlan_bridge
          up ip link set macvlan_bridge up
          post-up ip route add 192.168.1.254 dev macvlan_bridge
          post-up ip route add 192.168.1.253 dev macvlan_bridge
          post-up ip route add 192.168.1.252 dev macvlan_bridge
          post-up ip route add 192.168.1.250 dev macvlan_bridge
          post-up ip route add 192.168.1.248 dev macvlan_bridge
      
Description
No description provided
Readme MIT 37 KiB
Languages
Shell 100%