W Jean-Baptiste OnoFré's Blog Post, Apache KARAF & AMP; Docker, pokazuje, jak skonfigurować i uruchomić Apache Karaf wewnątrz kontenera dokującego.

Stworzyłem kontener za pomocą Skrypt Build.sh biegiem:

build.sh --from-release --karaf-version 4.2.7 --image-name karaf

Następnie uruchomiłem konsolę KARAF w pojemniku z:

docker-compose run karaf

Kiedy próbuję włączyć konsolę internetową, dostaję:

        __ __                  ____      
       / //_/____ __________ _/ __/      
      / ,<  / __ `/ ___/ __ `/ /_        
     / /| |/ /_/ / /  / /_/ / __/        
    /_/ |_|\__,_/_/   \__,_/_/         

  Apache Karaf (4.2.7)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

karaf@root()> feature:install webconsole
org.apache.karaf.features.internal.util.MultiException: Error:
    Error downloading mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.instance/4.2.7
    at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.<init>(MavenDownloadManager.java:91)
    at org.apache.karaf.features.internal.download.impl.MavenDownloadManager.createDownloader(MavenDownloadManager.java:72)
    at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:457)
    at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:452)
    at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:452)
    at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:224)
    at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:393)
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062)
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
    Suppressed: java.io.IOException: Error downloading mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.instance/4.2.7
        at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:77)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
        ... 3 more
    Caused by: java.io.IOException: Error resolving artifact org.apache.karaf.webconsole:org.apache.karaf.webconsole.instance:jar:4.2.7: [Could not transfer artifact org.apache.karaf.webconsole:org.apache.karaf.webconsole.instance:jar:4.2.7 from/to central (http://repo1.maven.org/maven2/): repo1.maven.org]
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)
        at org.apache.karaf.features.internal.download.impl.MavenDownloadTask.download(MavenDownloadTask.java:52)
        at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:60)
        ... 6 more
        Suppressed: shaded.org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.karaf.webconsole:org.apache.karaf.webconsole.instance:jar:4.2.7 from/to central (http://repo1.maven.org/maven2/): repo1.maven.org
            at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
            at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
            at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
            at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
            at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
            at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
            at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
            at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
            at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
            at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
            at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
            ... 11 more
        Caused by: shaded.org.apache.maven.wagon.TransferFailedException: repo1.maven.org
            at shaded.org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1184)
            at shaded.org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1072)
            at shaded.org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:126)
            at shaded.org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
            at shaded.org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
            at shaded.org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.java:567)
            at shaded.org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:435)
            at shaded.org.eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.java:412)
            at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:456)
            at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:363)
            ... 20 more
        Caused by: java.net.UnknownHostException: repo1.maven.org
            at java.base/java.net.InetAddress$CachedAddresses.get(Unknown Source)
            at java.base/java.net.InetAddress.getAllByName0(Unknown Source)
            at java.base/java.net.InetAddress.getAllByName(Unknown Source)
            at java.base/java.net.InetAddress.getAllByName(Unknown Source)
            at shaded.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
            at shaded.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
            at shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
            at shaded.org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
            at shaded.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
            at shaded.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
            at shaded.org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
            at shaded.org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
            at shaded.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
            at shaded.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
            at org.ops4j.pax.url.mvn.internal.wagon.ConfigurableHttpWagon.execute(ConfigurableHttpWagon.java:162)
            at shaded.org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1095)
            ... 29 more
    Caused by: shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error resolving artifact org.apache.karaf.webconsole:org.apache.karaf.webconsole.instance:jar:4.2.7
        at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)
        at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
        at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
        at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
        ... 11 more
Error executing command: Error:
    Error downloading mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.instance/4.2.7
karaf@root()>

Podstawowa przyczyna wydaje się:

Caused by: java.net.UnknownHostException: repo1.maven.org

Czy jest jakiś sposób, aby zmodyfikować mój pojemnik taki, że nie podniesie tego wyjątku podczas próby dotarcia do zewnętrznego repo maven?

0
Eric Green 25 grudzień 2019, 13:25

1 odpowiedź

Najlepsza odpowiedź

Spróbuj dodać rozdzielczość hosta do kompozycji dokera: extra_hosts: - "repo1.maven.org:162.242.195.82"

Wymień powyższy adres IP za pomocą poprawnego adresu IP.

0
AAber 26 grudzień 2019, 07:44