no internet inside docker-compose service

后端 未结 1 1086
执笔经年
执笔经年 2021-02-11 15:42

I cannot reach external network from docker-compose containers.

Consider the following docker-compose file:

version: \'2\'
services:
            


        
1条回答
  •  粉色の甜心
    2021-02-11 16:30

    The last time I had a problem like that, I solved it like this:

    https://github.com/docker/docker/issues/866#issuecomment-19218300

    pkill docker
    iptables -t nat -F
    ifconfig docker0 down
    brctl delbr docker0
    docker -d
    

    It will force docker to recreate the bridge and reinit all the network rules.

    As for reasons why this happens, I don't have good answers. But I did recently trace the problem back to journald. When I restart journald (for example because I changed its config), DNS resolution inside docker-compose containers consistently/reproducibly breaks. I don't know why exactly, I can only say that this is a reliable way for me to reproduce it on RHEL.

    EDIT The docker -d command might not work for you based on the version of docker you are using but don't worry about it, you can omit that command.

    0 讨论(0)
提交回复
热议问题