2

主机操作系统是Ubuntu 19.10。我已经成功地使用 启动了FreeIPA容器docker run,但我想让它在 compose 中工作。当我运行时docker-compose up,freeipa 崩溃并出现以下错误:

IPv6 stack is enabled in the kernel but there is no interface that has 
::1 address assigned. Add ::1 address resolution to 'lo' interface. 
You might need to enable IPv6 on the interface 'lo' in sysctl.conf.

我目前的配置:

freeipa:
        image: freeipa/freeipa-server
        command:
            [
                "--realm=${ROOT_DOMAIN}",
                "--ds-password=${LDAP_USER_PASSWORD}",
                "--admin-password=${LDAP_ADMIN_PASSWORD}",
                "-U",
            ]
        hostname: ${FREEIPA_DOMAIN}
        container_name: freeipa
        restart: unless-stopped
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.freeipa.rule=Host(`${FREEIPA_DOMAIN:?Domain for Freeipa must be set!}`)"
            - "traefik.http.routers.freeipa.entrypoints=secure"
            - "traefik.http.routers.freeipa.tls.certresolver=le"
        networks:
            - proxy
        volumes:
            - ${SERVICES_ROOT}/${FREEIPA_ROOT:-freeipa}/db:/data
            - ${SERVICES_ROOT}/${FREEIPA_ROOT:-freeipa}/logs:/var/logs
            - /sys/fs/cgroup:/sys/fs/cgroup:ro
        tmpfs:
            - /run
            - /var/cache
            - /tmp

在此处链接到完整(非常大)的撰写文件

我在 Docker 中启用了 ipv6 并重新加载了守护进程:

cat /etc/docker/daemon.json
{
        "ipv6": true,
        "fixed-cidr-v6": "2001:db8:1::/64"
}

这篇博文之后,我检查了容器中的接口配置:

$: docker run -itd ajeetraina/ubuntu-iproute bash
f549ae3efe887fe45a1594c87516b948cebbbb6916a6550d738e3271200bd9b7

$: docker exec -it f549 ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02
          inet addr:172.17.0.2  Bcast:172.17.255.255  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
          inet6 addr: 2001:db8:1::242:ac11:2/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:21 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3722 (3.7 KB)  TX bytes:726 (726.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

从我在这里看到的情况来看,环回设备似乎不应该有问题。

4

1 回答 1

4

我在一个不相关的 Github 问题中找到了答案。添加

sysctls:
    - net.ipv6.conf.all.disable_ipv6=0

服务定义解决了这个问题。我希望这可以帮助别人!

于 2020-04-15T16:20:19.467 回答