【docker挂载问题】( OCI runtime create failed: runc create failed)和 (java.nio.file.AccessDeniedException)

这篇具有很好参考价值的文章主要介绍了【docker挂载问题】( OCI runtime create failed: runc create failed)和 (java.nio.file.AccessDeniedException)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.故障现象:

阿里云ECS服务器:Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-73-generic x86_64)
上用docker部署elasticsearch服务。

因为偷懒直接用的 snap软件包管理器安装的docker。安装docker的版本信息为:
【docker挂载问题】( OCI runtime create failed: runc create failed)和 (java.nio.file.AccessDeniedException),排错日志,docker,java,nio
部署es或者redis等服务时,发现用docker挂载一直比较奇怪。要么是报错:

docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/data/redis/conf/redis.conf" to rootfs at "/etc/redis/redis.conf": mount /data/redis/conf/redis.conf:/etc/redis/redis.conf (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

大概意思是:把文件/data/redis/conf/redis.conf挂载到目录上 /etc/redis/redis.conf docker把挂载文件解析成了目录(/etc/redis/redis.conf),或者反向:把/data/redis/conf/redis.conf 解析成目录,/etc/redis/redis.conf解析成文件。所以报错,目录不能挂载到文件上。

要么是elasticsearch启动时报错:

root@i3rm4tzkh:/dockerdir/tools# docker logs -f es
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2023-08-24T01:47:35,687][INFO ][o.e.n.Node               ] [] initializing ...
[2023-08-24T01:47:35,704][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to create node environment
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.3.jar:6.4.3]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.3.jar:6.4.3]
Caused by: java.lang.IllegalStateException: Failed to create node environment
        at org.elasticsearch.node.Node.<init>(Node.java:277) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.node.Node.<init>(Node.java:256) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.3.jar:6.4.3]
        ... 6 more
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]
        at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:385) ~[?:?]
        at java.nio.file.Files.createDirectory(Files.java:682) ~[?:?]
        at java.nio.file.Files.createAndCheckIsDirectory(Files.java:789) ~[?:?]
        at java.nio.file.Files.createDirectories(Files.java:775) ~[?:?]
        at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:207) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.node.Node.<init>(Node.java:274) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.node.Node.<init>(Node.java:256) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.3.jar:6.4.3]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.3.jar:6.4.3]
        ... 6 more

另附运行脚本:

docker run -d --name es  -e "ES_JAVA_OPTS=-Xms4096m -Xmx4096m"  -e "discovery.type=single-node"  -v /data/elasticsearch/data:/usr/share/elasticsearch/data:rw  -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins:rw   --privileged  -p 9200:9200  -p 9300:9300 elasticsearch:6.4.3

2. 问题解决:

百度后做过各种尝试都没成功:

  1. /data/elasticsearch/data 修改目录权限 777
  2. 关闭 selinux
  3. 将挂载文件 改为挂载目录

各种尝试都失败后怀疑是es版本问题。修改es版本后结果问题依旧。

最终解决:找了个其他环境的docker版本:23.0.2 【问题解决】文章来源地址https://www.toymoban.com/news/detail-719714.html

root@iZwz93rm3yZ:~# docker version
Client: Docker Engine - Community
 Version:           23.0.2
 API version:       1.42
 Go version:        go1.19.7
 Git commit:        569dd73
 Built:             Mon Mar 27 16:16:30 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.2
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.7
  Git commit:       219f21b
  Built:            Mon Mar 27 16:16:30 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

到了这里,关于【docker挂载问题】( OCI runtime create failed: runc create failed)和 (java.nio.file.AccessDeniedException)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包