apple / apple/container

[Bug]: Could not resolve github.com in ubuntu container

Open
#283 8 comments 2 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
49.9k
Forks
1.8k
Avg merge
1d 20h
Merged PRs (30d)
22

Description

### I have done the following

- [x] I have searched the existing issues
- [ ] If possible, I've reproduced the issue using the 'main' branch of this project

### Steps to reproduce

## Env

Machine: M1 Macbook Air
OS: MacOS 15.5

container version:

```shell
container --version
container CLI version 0.2.0 (build: release, commit: 3b5c253)
```

IPs info
- `container ls` > buildkit container's IP ADDR: `192.168.79.2`
- `ifconfig` > bridge100 inet: `192.168.79.1`
- `container inspect buildkit | jq '.[0].configuration.dns.nameservers'`: 192.168.79.1

## Steps to reproduce

Originally this happened when I tried to build an image (see details below) with a Dockerfile which has a RUN command `curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb`. Afterwards, I found it also happened with the following steps:

1. Start a container `container run --rm -it ubuntu`
2. In container's bash

```shell
apt-get update && apt-get install curl -y
curl https://github.com
# curl: (6) Could not resolve host: github.com
```

Note: I also tried `curl https://www.apple.com` in container and it worked.

### Current behavior

### More details about the steps to reproduce

With the IPs above, running `container build` with a Dockerfile having a command `apt-get update` worked and resolved ubuntu.com on my side, but failed to resolve `github.com` when my Dockerfile has a RUN command `curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb`.

When the buildkit nameserver IP is consistent with my subnet, not sure why it could resolve ubuntu.com with apt-get but failed to resolve github.com with curl?

Dockerfile FYR:

```dockerfile
FROM ubuntu

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
unzip curl gnupg libgfortran5 libgbm1 tzdata netcat \
libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \
libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \
libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \
xdg-utils git build-essential ffmpeg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
# Install node and yarn
apt-get install -yq --no-install-recommends nodejs && \
curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \
&& dpkg -i yarn_1.22.19_all.deb \
&& rm yarn_1.22.19_all.deb

# ...
```

Error message:

```shell
72.02 Preparing to unpack .../nodejs_18.20.6-1nodesource1_arm64.deb ...
72.02 Unpacking nodejs (18.20.6-1nodesource1) ...
73.83 Setting up nodejs (18.20.6-1nodesource1) ...
73.85 % Total % Received % Xferd Average Speed Time Time Time Current
73.85 Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: github.com
```

### Expected behavior

curl `https://github.com` should work in the container.

### Environment

```markdown
- OS: macOS 15.5
- Container: 0.2.0 (build: release, commit: 3b5c253)
- Machine: M1 Macbook Air
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start by reproducing with `container run --rm -it ubuntu`, then compare DNS behavior for github.com and www.apple.com using the reported BuildKit nameserver 192.168.79.1 and bridge100. Trace the `container run` and build networking entry points; no source file or test is named in the issue. Done means curl can resolve and fetch https://github.com from the Ubuntu container.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, macos, swift
Domain
cli, networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.