I am setting up with docker-compose (version 1.21.1) 3 docker containers and two networks:

version: '2.1'
services:
  app1:
    build:
      context: .
      dockerfile: "Dockerfile"
    depends_on:
      - redis
    networks:
      - pub
      - default

  redis:
    build:
      context: "tests/redis"
    networks:
      - default

  app2:
    build:
      context: "tests/app2"
    networks:
      - pub
      - default

networks:
  pub:
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: "172.16.238.0/24"
        - subnet: "fe80::42:acff:fe10:ee04/64"
  default:

In app1:

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN     group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
696: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:10:ee:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0    
    inet 172.16.238.3/24 brd 172.16.238.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe10:ee03/64 scope link
       valid_lft forever preferred_lft forever
    inet6 fe80::3/64 scope link nodad
       valid_lft forever preferred_lft forever
698: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:c0:a8:f0:04 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.240.4/20 brd 192.168.255.255 scope global eth1
       valid_lft forever preferred_lft forever

However, I want eth1 to support IPv6, or both eth0 and eth1. The documentation doesn't mention anything about that, neither I could find an option in the network options. Is there a way to do this?

1 Answers

0
belabrinel On

I had to enable ipv6 for both networks and do subnetting to the IPv6 subnet. For the CIDR part I used an online subnet calculator for IPv6, however I am not sure yet why this worked :p

This is the configuration that worked:

networks:
  default:
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: "2001:db8:8000::/33"
  pub:
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: "2001:db8::/33"