Docker apt-get update fails

后端 未结 8 1273
天命终不由人
天命终不由人 2020-12-23 16:47

Can somebody help me get apt-get working in my docker container? Whenever I try running any apt-get command in my docker container, the command fails. I\'m running Docker ve

8条回答
  •  一向
    一向 (楼主)
    2020-12-23 17:14

    Thanks for all your help! I found out it was a dns problem and that it was because of a firewall. After searching some more I found this question that I wasn't able to find while searching 'docker apt-get fail'

    Docker - Network calls fail during image build on corporate network

    His problem was similar to mine and the solution helped me get it working. I've copied over his solution for anybody that finds this question in the future.

    Those Google servers weren't accessible from behind our firewall, which is why we couldn't resolve any URLs.

    The fix is to tell Docker which DNS servers to use. This fix depends on how you installed Docker: Ubuntu Package

    If you have the Ubuntu package installed, edit /etc/default/docker and add the following line:

    DOCKER_OPTS="--dns --dns "

    You can add as many DNS servers as you want to this config. Once you've edited this file you'll want to restart your Docker service:

    sudo service docker restart

    Binaries

    If you've installed Docker via the binaries method (i.e. no package), then you set the DNS servers when you start the Docker daemon:

    sudo docker -d -D --dns --dns &

提交回复
热议问题