文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

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

2023-10-18 15:17

关注

1.故障现象:

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

因为偷懒直接用的 snap软件包管理器安装的docker。安装docker的版本信息为:
在这里插入图片描述
部署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 esOpenJDK 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.(Node.java:277) ~[elasticsearch-6.4.3.jar:6.4.3]        at org.elasticsearch.node.Node.(Node.java:256) ~[elasticsearch-6.4.3.jar:6.4.3]        at org.elasticsearch.bootstrap.Bootstrap$5.(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 moreCaused 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.(NodeEnvironment.java:207) ~[elasticsearch-6.4.3.jar:6.4.3]        at org.elasticsearch.node.Node.(Node.java:274) ~[elasticsearch-6.4.3.jar:6.4.3]        at org.elasticsearch.node.Node.(Node.java:256) ~[elasticsearch-6.4.3.jar:6.4.3]        at org.elasticsearch.bootstrap.Bootstrap$5.(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 【问题解决】

root@iZwz93rm3yZ:~# docker versionClient: 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:           defaultServer: 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

来源地址:https://blog.csdn.net/d495435207/article/details/132467445

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯