toolbox icon indicating copy to clipboard operation
toolbox copied to clipboard

Can't resolve host `toolbox` inside `fedora-toolbox:40` container

Open 0rzech opened this issue 1 year ago • 5 comments

Describe the bug

Quarkus application runs fine when started inside fedora-toolbox:39 container. But inside fedora-toolbox:40, a java.net.UnknownHostException: toolbox gets thrown.

Steps how to reproduce the behaviour

  1. Create a fresh F40 toolbox container with toolbox create.
  2. Run sudo dnf install --setopt=install_weak_deps=False java-21-openjdk-devel inside container.
  3. Run quarkus dev or quarkus test inside container.
  4. See the error.

Expected behaviour

Java should not throw the aforementioned exception.

Actual behaviour

Upon starting Quarkus application, the following warning is printed and exception is thrown:

[WARNING] Failed to get hostname, using 'localhost'
java.net.UnknownHostException: toolbox: toolbox: Ta nazwa lub usługa jest nieznana
    at java.net.InetAddress.getLocalHost (InetAddress.java:1936)
    at org.eclipse.aether.internal.impl.synccontext.named.DiscriminatingNameMapper.getHostname (DiscriminatingNameMapper.java:90)
    at org.eclipse.aether.internal.impl.synccontext.named.DiscriminatingNameMapper.<init> (DiscriminatingNameMapper.java:69)
    at org.eclipse.aether.internal.impl.synccontext.named.NameMappers.discriminatingNameMapper (NameMappers.java:68)
    at org.eclipse.aether.internal.impl.synccontext.named.providers.DiscriminatingNameMapperProvider.<init> (DiscriminatingNameMapperProvider.java:39)
    at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance (DirectConstructorHandleAccessor.java:62)
    at java.lang.reflect.Constructor.newInstanceWithCaller (Constructor.java:502)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:486)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:34)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.BeanSupplier.lambda$transform$1 (BeanSupplier.java:42)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getAllBeansWithNames (Scope.java:145)
    at io.smallrye.beanbag.AllBeansWithNamesResolver.get (AllBeansWithNamesResolver.java:18)
    at io.smallrye.beanbag.AllBeansWithNamesResolver.get (AllBeansWithNamesResolver.java:8)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.Scope.requireBean (Scope.java:164)
    at io.smallrye.beanbag.BeanBag.requireBean (BeanBag.java:84)
    at io.smallrye.beanbag.maven.MavenFactory.getRepositorySystem (MavenFactory.java:167)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.initRepoSystemAndManager (BootstrapMavenContext.java:878)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRepositorySystem (BootstrapMavenContext.java:292)
    at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.<init> (MavenArtifactResolver.java:114)
    at io.quarkus.maven.components.QuarkusWorkspaceProvider.createArtifactResolver (QuarkusWorkspaceProvider.java:115)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.artifactResolver (QuarkusBootstrapProvider.java:181)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.doBootstrap (QuarkusBootstrapProvider.java:207)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.bootstrapApplication (QuarkusBootstrapProvider.java:351)
    at io.quarkus.maven.QuarkusBootstrapProvider.bootstrapApplication (QuarkusBootstrapProvider.java:128)
    at io.quarkus.maven.QuarkusBootstrapMojo.bootstrapApplication (QuarkusBootstrapMojo.java:294)
    at io.quarkus.maven.GenerateCodeMojo.generateCode (GenerateCodeMojo.java:79)
    at io.quarkus.maven.GenerateCodeTestsMojo.doExecute (GenerateCodeTestsMojo.java:13)
    at io.quarkus.maven.QuarkusBootstrapMojo.execute (QuarkusBootstrapMojo.java:169)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
Caused by: java.net.UnknownHostException: toolbox: Ta nazwa lub usługa jest nieznana
    at java.net.Inet6AddressImpl.lookupAllHostAddr (Native Method)
    at java.net.Inet6AddressImpl.lookupAllHostAddr (Inet6AddressImpl.java:52)
    at java.net.InetAddress$PlatformResolver.lookupByName (InetAddress.java:1211)
    at java.net.InetAddress.getAddressesFromNameService (InetAddress.java:1828)
    at java.net.InetAddress$NameServiceAddresses.get (InetAddress.java:1139)
    at java.net.InetAddress.getAllByName0 (InetAddress.java:1818)
    at java.net.InetAddress.getLocalHost (InetAddress.java:1931)
    at org.eclipse.aether.internal.impl.synccontext.named.DiscriminatingNameMapper.getHostname (DiscriminatingNameMapper.java:90)
    at org.eclipse.aether.internal.impl.synccontext.named.DiscriminatingNameMapper.<init> (DiscriminatingNameMapper.java:69)
    at org.eclipse.aether.internal.impl.synccontext.named.NameMappers.discriminatingNameMapper (NameMappers.java:68)
    at org.eclipse.aether.internal.impl.synccontext.named.providers.DiscriminatingNameMapperProvider.<init> (DiscriminatingNameMapperProvider.java:39)
    at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance (DirectConstructorHandleAccessor.java:62)
    at java.lang.reflect.Constructor.newInstanceWithCaller (Constructor.java:502)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:486)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:34)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.BeanSupplier.lambda$transform$1 (BeanSupplier.java:42)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getAllBeansWithNames (Scope.java:145)
    at io.smallrye.beanbag.AllBeansWithNamesResolver.get (AllBeansWithNamesResolver.java:18)
    at io.smallrye.beanbag.AllBeansWithNamesResolver.get (AllBeansWithNamesResolver.java:8)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.BeanResolver.get (BeanResolver.java:20)
    at io.smallrye.beanbag.ConstructorSupplier.get (ConstructorSupplier.java:27)
    at io.smallrye.beanbag.Bean$Pending.get (Bean.java:125)
    at io.smallrye.beanbag.Bean.get (Bean.java:47)
    at io.smallrye.beanbag.Scope.getBean (Scope.java:237)
    at io.smallrye.beanbag.Scope.requireBean (Scope.java:164)
    at io.smallrye.beanbag.BeanBag.requireBean (BeanBag.java:84)
    at io.smallrye.beanbag.maven.MavenFactory.getRepositorySystem (MavenFactory.java:167)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.initRepoSystemAndManager (BootstrapMavenContext.java:878)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRepositorySystem (BootstrapMavenContext.java:292)
    at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.<init> (MavenArtifactResolver.java:114)
    at io.quarkus.maven.components.QuarkusWorkspaceProvider.createArtifactResolver (QuarkusWorkspaceProvider.java:115)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.artifactResolver (QuarkusBootstrapProvider.java:181)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.doBootstrap (QuarkusBootstrapProvider.java:207)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.bootstrapApplication (QuarkusBootstrapProvider.java:351)
    at io.quarkus.maven.QuarkusBootstrapProvider.bootstrapApplication (QuarkusBootstrapProvider.java:128)
    at io.quarkus.maven.QuarkusBootstrapMojo.bootstrapApplication (QuarkusBootstrapMojo.java:294)
    at io.quarkus.maven.GenerateCodeMojo.generateCode (GenerateCodeMojo.java:79)
    at io.quarkus.maven.GenerateCodeTestsMojo.doExecute (GenerateCodeTestsMojo.java:13)
    at io.quarkus.maven.QuarkusBootstrapMojo.execute (QuarkusBootstrapMojo.java:169)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)

Screenshots

N/A

Output of toolbox --version (v0.0.90+)

toolbox version 0.0.99.5

Toolbx package info (rpm -q toolbox)

toolbox-0.0.99.5-8.fc40.x86_64

Output of podman version

Client:       Podman Engine
Version:      5.0.3
API Version:  5.0.3
Go Version:   go1.22.2
Built:        Fri May 10 02:00:00 2024
OS/Arch:      linux/amd64

Podman package info (rpm -q podman)

podman-5.0.3-1.fc40.x86_64

Info about your OS

Fedora Silverblue 40

Additional context

Running podman system reset did not help.

0rzech avatar May 22 '24 18:05 0rzech

The mentioned steps are not enough to reproduce the exact error (requires also installing quarkus), but the java.net.UnknownHostException: toolbox suggests there is some kind of change to the network settings of the toolbox container, not specific to Java/Quarkus.

In the test below, I think we can see the same problem just by using the default programs included in the toolbox image.

fedora-toolbox:39 (works)

[user@toolbox ~]$ cat /etc/fedora-release 
Fedora release 39 (Thirty Nine)
[user@toolbox ~]$ cat /etc/hostname
toolbox[user@toolbox ~]$ 
[user@toolbox ~]$ hostname -s
toolbox
[user@toolbox ~]$ hostname -f
toolbox
[user@toolbox ~]$ curl -v http://toolbox
* processing: http://toolbox
*   Trying [fe80::fae3:66bc:a805:3bc6]:80...
*   Trying 10.97.21.241:80...

fedora-toolbox:40 (doesn't work)

[user@toolbox ~]$ cat /etc/fedora-release 
Fedora release 40 (Forty)
[user@toolbox ~]$ cat /etc/hostname 
toolbox[user@toolbox ~]$ 
[user@toolbox ~]$ hostname -s
toolbox
[user@toolbox ~]$ hostname -f
hostname: Name or service not known
[user@toolbox ~]$ curl -v http://toolbox
* Could not resolve host: toolbox
* Closing connection
curl: (6) Could not resolve host: toolbox

Environment

Fedora Linux 40.20240512.0 (Silverblue)
toolbox version 0.0.99.5
toolbox-0.0.99.5-8.fc40.x86_64

There is a difference in how fedora-toolbox:39 and fedora-toolbox:40 set their FQDN hostname, as hostname -f unexpectedly fails in 40. Then, I am using curl just to check the DNS resolution, as the toolbox doesn't have dig/nslookup/etc. Didn't notice any interesting changes to /etc/hosts or /etc/resolv.conf, but there must be something else going on.

There are a number of other Issues/PRs in this repo about DNS and hostname changes, but I'm unclear which could be related or not.

bwenrich avatar May 27 '24 15:05 bwenrich

There are some changes to /etc/resolv.conf symlink in #1410, could they be related? I can reproduce this issue on my system -

toolbox version 0.0.99.5
toolbox-0.0.99.5-11.fc40.x86_64
Fedora Linux 40 (Workstation Edition)

devcode11 avatar Jun 12 '24 07:06 devcode11

I've been having trouble with X11 programs running in Toolbox containers in Kinoite. The whole KDE desktop (wayland) hangs for several seconds when an X-application (especially Wrye Bash, https://github.com/wrye-bash/wrye-bash, but also vim) opens dialogs or context menus.

Running "sudo hostname localhost" in the toolbox container resolved the issue and X-applications seem to run fine now without hanging the rest of the desktop.

neutronleak avatar Jul 02 '24 08:07 neutronleak

This issue also seems to result in commands such as sudo dnf install ... taking quite a bit longer than expected, likely due to it failing to resolve the hostname. https://github.com/containers/toolbox/pull/1086 has been open for little over two years, but it's seemingly going nowhere.

A workaround is to add 127.0.0.1 toolbox to /etc/hosts on the host, then restart the host network, and restart the container (or recreate it if possible, for good measure). At this point the hostname should resolve just fine.

yorickpeterse avatar Aug 24 '24 23:08 yorickpeterse

I am no longer able to reproduce this issue after upgrading to Fedora Silverblue 41 w/ Toolbox v0.1.0. In all cases, the hostname inside the toolbox is reported as toolbx (instead of toolbox previously), and that is resolvable in DNS. Clearly there have been more changes somewhere that impact how hostnames work within the toolbox.

Environment

Fedora Linux 41.20241109.0 (Silverblue)
toolbox-0.1.0-1.fc41.x86_64
podman-5.2.5-1.fc41.x86_64

Toolbox - Fedora 40

[user@toolbx ~]$ cat /etc/fedora-release 
Fedora release 40 (Forty)
⬢ [user@toolbx ~]$ cat /etc/hostname 
toolbx
⬢ [user@toolbx ~]$ hostname -s
toolbx
⬢ [user@toolbx ~]$ hostname -f
toolbx
⬢ [user@toolbx ~]$ curl -v http://toolbx
* Host toolbx:80 was resolved.
* IPv6: fe80::f91d:xxxx:xxxx:179c, 2601:182:b01:8901:xxxx:xxxx:3718:6618
* IPv4: 10.90.21.237

Toolbox - Fedora 41

⬢ [user@toolbx ~]$ cat /etc/fedora-release 
Fedora release 41 (Forty One)
⬢ [user@toolbx ~]$ cat /etc/hostname 
toolbx
⬢ [user@toolbx ~]$ hostname -s
toolbx
⬢ [user@toolbx ~]$ hostname -f
toolbx
⬢ [user@toolbx ~]$ curl -v http://toolbx
* Host toolbx:80 was resolved.
* IPv6: fe80::f91d:xxxx:xxxx:179c, 2601:182:b01:8901:xxxx:xxxx:3718:6618
* IPv4: 10.90.21.237

bwenrich avatar Nov 09 '24 23:11 bwenrich

Same as above.

0rzech avatar May 10 '25 23:05 0rzech