Skip to content
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

Docker: Use hostname instead of IP addresses #453

Closed
shred opened this issue Mar 22, 2024 · 7 comments
Closed

Docker: Use hostname instead of IP addresses #453

shred opened this issue Mar 22, 2024 · 7 comments

Comments

@shred
Copy link
Contributor

shred commented Mar 22, 2024

Is it possible to use hostnames as parameters, instead of IP addresses?

Currently, the docker-compose file uses a subnet and fixed IP addresses. I cannot set up a docker network in my integration tests though (long story), so I have to do ugly workarounds.

With hostnames instead of IPs, this would be possible (if I'm not mistaken):

version: "3"
services:
  pebble:
    image: ghcr.io/letsencrypt/pebble:latest
    command: -config test/config/pebble-config.json -strict -dnsserver challtestsrv:8053
    ports:
      - 14000:14000
      - 15000:15000
  challtestsrv:
    image: ghcr.io/letsencrypt/pebble-challtestsrv:latest
    command: -defaultIPv6 "" -defaultIPv4 challtestsrv
    ports:
      - 8055:8055
@pgporada
Copy link
Member

pgporada commented Mar 22, 2024 via email

@shred
Copy link
Contributor Author

shred commented Mar 22, 2024

OK, let's make a short story long. 😉 I'm running integration tests in Java, and I'm starting the docker containers from the build script.

I have used a construct like this, where getent hosts resolved the IP from /etc/hosts:

  <arg>sh</arg>
  <arg>-c</arg>
  <arg>pebble -strict -dnsserver $(getent hosts challtestsrv|cut -d' ' -f1):8053 -config /test/config/pebble-config.json</arg>

Unfortunately it won't work anymore, because the new pebble and challtestsrv images are based on the scratch image, so there are no commands like getent, or even cut.

Then I tried to set up a network with fixed IP addresses, like in Pebble's docker-compose.yml. But the docker extension of my build tool is unable to set up networks, neither in the build script nor by using docker compose. I would have to set up the network manually before running the integration tests.

My current solution is to build fresh docker images based on alpine, and "steal" the relevant application files from the new pebble and challtestsrv docker images. Now I can do my getent hosts challtestsrv trick again. (Well, it works, but it won't win a beauty pageant.)

In my example above, it would be unnecessary to set up a subnet with fixed IP addresses, and I also wouldn't need the getent trick.

@mcpherrinm
Copy link
Contributor

mcpherrinm commented May 15, 2024

We should be able to support hostnames instead of hardcoded IPs, and I think that makes sense to do. I'll take a bit of a run at it.

@mitar
Copy link

mitar commented May 16, 2024

Duplicate of #418?

@mitar
Copy link

mitar commented May 16, 2024

There is PR with the fix: letsencrypt/challtestsrv#20

@mcpherrinm
Copy link
Contributor

Thanks @mitar, I didn't notice that PR (sorry, I wasn't watching the challtestsrv github repo). Yes, I do think that's a duplicate, and we can use your work there.

@shred
Copy link
Contributor Author

shred commented May 23, 2024

On Pebble's side, the -dnsserver option already seems to accept hostnames. So @mitar's PR would resolve this issue.

I'm closing it as duplicate. Thank you!

@shred shred closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants