vscode-dev-containers
vscode-dev-containers copied to clipboard
Dev Container suddenly cannot access Internet today
I could access internet in my VScode dev container yesterday, but not today. I checked the host machine (Ec2 instance) can access internet without problem by running
curl -Is www.google.com | head -n 1
> HTTP/1.1 200 OK
Yet in the dev container, it hangs due to no access to internet.
So I decided to rebuild the dev container, without any change to my .devcontainer/devcontainer.json
and made no change to my Dockerfile
, but rebuild started to fail due to no access to internet (My Dockerfile needs internet to install some packages, my postCreateCommand needs internet to install Python packages):
.devcontainer/devcontainer.json
:
{
"name": "Test",
"build": {
"dockerfile": "../Dockerfile",
"context": ".."
},
"runArgs": [ "--network", "host"],
"postCreateCommand": "pip install pandas"
}
and
Dockerfile
:
ARG VARIANT=3.8
FROM mcr.microsoft.com/devcontainers/python:0-${VARIANT}
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install -y libsasl2-modules libsasl2-dev
Is this related to new release of VScode? How to fix it to be able to access internet inside dev container during Dockerfile build, and also post build?
I tried removing "runArgs": [ "--network", "host"]
but it also results in failure to build the dev container.
This seems to only happen on my EC2 dev instance, not my Macbook, so it's extra strange
Same thing started happening to me today. Running Debian 12 Bookworm as the host, I can build the image by hand by running docker build
, but building through VSCode seems to fail with a network error. Very strange, and I'm pulling my hair out trying to get this working as I need to work... I also had --network host
included in my runArgs
. Did you ever find a solution to this?