-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfile
: Remove /etc/nsswitch.conf
workaround
#3685
Comments
ContextWhen
Thus the workaround of adding a VerificationThe original golang bug report has a simple reproduction with building a basic Go program. However to easily reproduce the bug and that demonstrate the fix, I've provided an alternative reproduction that compares past Caddy image releases. Additional info - References & Timeline (click to expand)
Reproduction ConfigUsing Docker Compose, all we need is a single # compose.yaml
services:
example:
image: go-dns-bug
container_name: nsswitch-example
# Inline Dockerfile build
# Purpose: Remove `/etc/nsswitch.conf` from the image
build:
# CADDY_VERSION below is not a Dockerfile build ARG,
# Within a compose config, it is interpolated from ENV:
# https://docs.docker.com/compose/environment-variables/env-file/#interpolation
dockerfile_inline: |
FROM caddy:${CADDY_VERSION:-2.3.0}-alpine AS base
FROM base AS remove-conf
RUN rm /etc/nsswitch.conf
# Using an ENV, can change the build target to toggle removing /etc/nsswitch.conf
target: ${BUILD_TARGET:-remove-conf}
# Assists with prune filter for cleanup afterwards, as base images are years old:
labels:
- "prune-marker=go-dns-bug"
# Appends to the run-time generated `/etc/hosts`:
extra_hosts:
- "example.com:127.0.0.1"
ports:
- "80:80"
configs:
- source: caddyfile
target: /etc/caddy/Caddyfile
# Inline config file content requires Docker Compose v2.23.1 (Nov 2023).
# For earlier releases, create a file with the content and
# volume mount it to: /etc/caddy/Caddyfile
configs:
caddyfile:
content: |
{
admin example.com:1337
}
# Optional, can test connection with `curl localhost`
:80 {
log
respond "hello!"
}
Reproduction CommandsThe above This makes it simple to run a few commands to test the following variants with ENV vars. # The default will fail (Caddy 2.3.0 with `/etc/nsswitch.conf` removed):
$ docker compose up --force-recreate --build
nsswitch-example | run: loading initial config: loading new config: starting caddy administration endpoint: listen tcp 93.184.216.34:1337: bind: cannot assign requested address
nsswitch-example exited with code 1
# Caddy 2.3.0 with `/etc/nsswitch.conf` provided from image works (`/etc/hosts` takes priority over DNS lookup):
$ BUILD_TARGET=base docker compose up --force-recreate --build
# Caddy 2.4.0 is consistent with or without `/etc/nsswitch.conf`,
# due to the release being built with Go 1.16 that fixes the logic:
$ CADDY_VERSION=2.4.0 BUILD_TARGET=base docker compose up --force-recreate --build
$ CADDY_VERSION=2.4.0 docker compose up --force-recreate --build Context for above commands (collapsed for brevity)
Optionally test the connection is working: # `-w "\n"` is only to avoid affecting the terminal prompt position
$ curl -w "\n" localhost
hello! For proper reproduction, it's worth noting that the Caddyfile configured
Reproduction Cleanup$ docker compose down
# Target the images created for pruning via a label filter,
# since the base images (now untagged) are from years ago:
$ docker image prune --all --filter 'label=prune-marker=go-dns-bug' Additional InfoRelated to the topic, but not relevant. In Nov 2022, Go 1.20 (released Feb 2023) changes DNS for macOS to always defer to the system DNS resolver, regardless of |
Hello contributors! I am marking this issue as stale as it has not received any engagement from the community or maintainers for a year. That does not imply that the issue has no merit! If you feel strongly about this issue
Throughout its lifetime, Ory has received over 10.000 issues and PRs. To sustain that growth, we need to prioritize and focus on issues that are important to the community. A good indication of importance, and thus priority, is activity on a topic. Unfortunately, burnout has become a topic of concern amongst open-source projects. It can lead to severe personal and health issues as well as opening catastrophic attack vectors. The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone. If this issue was marked as stale erroneously you can exempt it by adding the Thank you for your understanding and to anyone who participated in the conversation! And as written above, please do participate in the conversation if this topic is important to you! Thank you 🙏✌️ |
Preflight checklist
Describe your problem
Some of the
Dockerfile
files in this repo (and likely other Ory projects) carry an old workaround (introduced in April 2020):hydra/.docker/Dockerfile-alpine
Lines 9 to 11 in f9cee32
hydra/.docker/Dockerfile-scratch
Lines 5 to 7 in f9cee32
This is no longer relevant since Alpine 3.16.3 which now includes
/etc/nsswitch.conf
, additionally since Go 1.16 the referenced logic has been changed to not preferdns files
, but insteadfiles dns
(preferring/etc/hosts
before querying DNS).Describe your ideal solution
Remove the relevant lines from the
Dockerfile
files across Ory projects.Workarounds or alternatives
No issue, just communicating that the content is redundant to maintainers.
Version
2.1.2
The text was updated successfully, but these errors were encountered: