title: docker-compose container cannot access Internet
body: <p>I'm not using any proxy. But my hosting provider has it's own nameservers which configured fine and work. I have set them also in <code>/etc/docker/daemon.json</code>. Restarted docker &amp; tested. Then checked journal and saw that those nameservers responded fine. I also know that docker-compose create custom user network for containers in build and that those are not using resolv.conf's nameservers and instead used built in DNS server within docker. Still i need ability to install something inside containers and even <code>apt-get update</code> are failed, how can i fix this?</p>
  <pre><code>apt-get update
  Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
    Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
  Err:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
    Unable to connect to archive.ubuntu.com:http:
  Err:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
    Unable to connect to archive.ubuntu.com:http:
  Err:4 http://downloads.mariadb.com/MariaDB/mariadb-10.4/repo/ubuntu bionic InRelease
    Could not connect to downloads.mariadb.com:80 (172.67.32.229), connection timed out Could not connect to downloads.mariadb.com:80 (104.20.68.208), connection timed out Could not connect to downloads.mariadb.com:80 (104.20.67.208), connection timed out
  Err:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
    Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out
  Reading package lists... Done
  W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
  W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Unable to connect to archive.ubuntu.com:http:
  W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Unable to connect to archive.ubuntu.com:http:
  W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out
  W: Failed to fetch http://downloads.mariadb.com/MariaDB/mariadb-10.4/repo/ubuntu/dists/bionic/InRelease  Could not connect to downloads.mariadb.com:80 (172.67.32.229), connection timed out Could not connect to downloads.mariadb.com:80 (104.20.68.208), connection timed out Could not connect to downloads.mariadb.com:80 (104.20.67.208), connection timed out
  W: Some index files failed to download. They have been ignored, or old ones used instead.
  </code></pre>
  <p>iptables rules outside the container(on host machine):</p>
  <pre><code>sudo iptables -L
  Chain INPUT (policy ACCEPT)
  target     prot opt source               destination
  
  Chain FORWARD (policy DROP)
  target     prot opt source               destination
  DOCKER-USER  all  --  anywhere             anywhere
  DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
  DOCKER     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
  DOCKER     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
  DOCKER     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  
  Chain OUTPUT (policy ACCEPT)
  target     prot opt source               destination
  
  Chain DOCKER (3 references)
  target     prot opt source               destination
  ACCEPT     tcp  --  anywhere             172.17.0.2           tcp dpt:mysql
  ACCEPT     tcp  --  anywhere             172.17.0.3           tcp dpt:https
  ACCEPT     tcp  --  anywhere             172.17.0.3           tcp dpt:http
  
  Chain DOCKER-ISOLATION-STAGE-1 (1 references)
  target     prot opt source               destination
  DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
  DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
  DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
  RETURN     all  --  anywhere             anywhere
  
  Chain DOCKER-ISOLATION-STAGE-2 (3 references)
  target     prot opt source               destination
  DROP       all  --  anywhere             anywhere
  DROP       all  --  anywhere             anywhere
  DROP       all  --  anywhere             anywhere
  RETURN     all  --  anywhere             anywhere
  
  Chain DOCKER-USER (1 references)
  target     prot opt source               destination
  RETURN     all  --  anywhere             anywhere
  </code></pre>
  <p>It's just connection timed out. I don't think it is nameservers. And firewalld (NetworkManager) are not installed at all, since it have conflict with docker. Thanks, if anyone will be able to help me.</p>