No internet access in the Docker Containers

Hello everyone! Hope you all are doing great.
I’m new to Docker. I deployed Docker on the Raspberry Pi4 4GB model.

The problem I’m fetching is, none of my docker containers can communicate with the internet. I tried with a fresh install using Raspbian OS lite (Based on Debian Buster) but nothing works. I followed the official documentation for installing docker on my raspberry pi4. I opened TCP ports 80 & 443 to the raspberry pi server but nothing helps. Neither I can reach my docker containers from outside of my network, nor the containers can use the internet from inside docker.
I need to deploy the NextCloud container on my raspberry pi, so internet access to NextCloud is needed here. I followed several youtube tutorials about deploying the nexcloud container in raspberry pi, I did the exact same thing which they did and instructed me to do but my containers can’t access the internet. I’m not sure what I did wrong.
I guess there’s something I’m missing in the docker networking. But as I told you before, I’m new to Docker, so I can’t resolve it by myself!

I installed Nginx Proxy Manager in my docker but it’s not functioning properly as it doesn’t have internet access.
I’m using a MikroTik router (model RB951G-2HnD). In my router, I configured “dst-nat” of ports 80 and 443 to my raspberry pi. And Nginx Proxy Manager is listening to ports 80 and 443. I did nothing else in my MikroTik. Do I need to configure anything else in MikroTik to give access to my containers to the internet?
I’m consistently trying to solve this problem for the last 7-10 days but found nothing that helps in my case. Could it be the problem with the Official Image of docker or Debian? I don’t know but it’s not working in my case!

The software and hardware I’m using:

  • Raspberry Pi4 (4GB)
  • OS: Latest RaspbianOS Lite (Debian)
  • Debian Version: 10.9
  • Router: RB951G-2HnD

Docker Version:
Client: Docker Engine - Community
Version: 20.10.6
API version: 1.41
Go version: go1.13.15
Git commit: 370c289
Built: Fri Apr 9 22:46:15 2021
OS/Arch: linux/arm
Context: default
Experimental: true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:17 2021
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Please guys help me out here, I’m got really frustrated. Please suggest what can I do now?

Have you exposed and mapped the ports on the container?
Additionally you can try running your container by specifying the --net=host flag, this will tie your container to the host network and not to the default docker bridge network .

This can be potentially insecure however it is a good starting point in my opinion.

2 Likes

Worked on my case! Thank you so much!

Thank you. This one works for me. Tried --env http_proxy but failed and this solution saved my life

Docker networking can be tricky. This article explains how to use docker networks in a docker-compose file.