微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Docker中装载卷时无法访问jarfile错误

如何解决在Docker中装载卷时无法访问jarfile错误

我有一个Docker容器,该容器执行打包为 fat-jar 的Java应用程序(即,随附所有依赖项)。 Dockerfile在GitHub中是公共的,而容器在Docker Hub中是公共的。请注意,由于我需要将参数(称为CMD)传递给ENTRYPOINT,因此我在Dockerfile中使用broWSER而不是java -jar

当我按如下方式运行Docker容器时,一切正常:

$ docker run --rm -e broWSER=chrome bonigarcia/webdrivermanager:4.1.0
[INFO] Using WebDriverManager to resolve chrome
[DEBUG] Created new resolution cache file at /root/.m2/repository/webdriver/resolution.properties
[DEBUG] Running command on the shell: [google-chrome,--version]
[DEBUG] There was a problem executing command <google-chrome --version> on the shell: Cannot run program "google-chrome" (in directory "."): error=2,No such file or directory
[DEBUG] Result: 
[DEBUG] The driver version for Chrome is unkNown ... trying with latest
[DEBUG] Latest version of chromedriver according to https://chromedriver.storage.googleapis.com/LATEST_RELEASE is 84.0.4147.30
[INFO] Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
[DEBUG] Driver to be downloaded chromedriver 84.0.4147.30
[INFO] Downloading https://chromedriver.storage.googleapis.com/84.0.4147.30/chromedriver_linux64.zip
[INFO] Extracting binary from compressed file chromedriver_linux64.zip
[INFO] Driver location: /wdm/chromedriver

按如下所示映射卷时会发生问题:

$ docker run --rm -e broWSER=chrome -v ${PWD}:/wdm bonigarcia/webdrivermanager:4.1.0
Error: Unable to access jarfile webdrivermanager-4.1.0-fat.jar

有人知道如何映射所需的卷并避免此错误吗?

解决方法

构建映像时,this.hnService.getNewStories().pipe( .mergeMap(data => this.hnService.getItem(data)) .subscribe(res => this.stories = res); 被复制到docker容器内的df.groupby(df.index // 3).agg({'High':'max','Low': 'max','Close':'max','Date': 'first'}) 目录中。然后,当您使用webdrivermanager-${VERSION}-fat.jar启动容器时,/wdm的目录-v ${PWD}:/wdm/wdm屏蔽,因此JAR文件不存在。

我猜,您要实现的目标是使从主机可以访问容器下载的驱动程序。一种可能的解决方案是将其下载到与放置JAR所在的目录不同的目录,然后安装该下载目录。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。