Docker can't seem to connect to internet from inside container

Hey folks,

Not sure where that issue comes from. I’ve never experienced that on any other distribution. I’ve come across a couple of workarounds on Stack Overflow but most are pretty dates and don’t seem to fix it for me.

Basically, my containers can’t connect to the internet. For example if I run

docker run ubuntu apt-get update

I will get the following output

    $ docker run ubuntu apt-get update                        
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
54ee1f796a1e: Pull complete 
f7bfea53ad12: Pull complete 
46d371e02073: Pull complete 
b66c17bbf772: Pull complete 
Digest: sha256:31dfb10d52ce76c5ca0aa19d10b3e6424b830729e32a89a7c6eee2cda2be67a5
Status: Downloaded newer image for ubuntu:latest
Err:1 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Any pointers would be greatly appreciated! So far it’s the only thing that makes me want to go back to Pop!_OS even though I absolutely love Manjaro Xfce

Execute a:

docker exec --interactive --tty <container-id> /bin/bash

Where <container-id> is obviously the container ID

Then within the container, execute:

ip address
traceroute security.ubuntu.com
traceroute 91.189.88.152
nslookup security.ubuntu.com
ping 1.1.1.1

to give us some more tangible data to work with, please?

:innocent:

Good call, thanks!
Actually, for some odd reason, it was working yesterday but anymore now, ah well.

Now if I hook into my ubuntu container I can’t run ip address or traceroute or anything as it doesn’t have any package. Not sure what I’m doing wrong here

❯ docker run -ti ubuntu /bin/bash
root@e7b75efd9b1a:/# traceroute
bash: traceroute: command not found

Yup. minimal Ubuntu install to keep the container small too.

This looks like an XY problem. What are you trying to accomplish and why?

:thinking:

Aha fair enough.
The ubuntu container is really used just to illustrate the issue. The real problem I’m having is using Docker to develop a Python app.
In my Dockerfile I have a

RUN pip install bottle

That fails to run since it’s failing to connect to the internet.

Then again, it was working fine at some point so I may have messed something up. It looks like the Arch install of Docker requires a little more tinkering or maybe it’s just my setup

There you go! The answer is: You don’t: Docker is to deploy applications and you develop in Manjaro and then package your application files into a Docker file.

Have a read here

:wink:

Sorry I’m phrasing things badly I suppose, I have a Python app I’m trying to “dockerize” just so it’s easier to deploy to AWS via a ECR, anyway, long story short…
It seems to work ok now, I tried the following:

FROM python:3.8
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
CMD python ./index.py

and it works :confused:

ah well, sorry for taking up your time and for the rather confusing way my issue was layed out.

2 Likes