1
我試圖在安裝了Docker 1.12.5的新創建的虛擬機上運行ElasticSearch容器,但遇到Permission Denied
異常。令我感到困惑的是,在我的老VM中,Docker 1.12.2的一切運行良好。我錯過了什麼?運行容器時的權限被拒絕(docker 1.12.5)
異常:
Exception in thread "main" SettingsException[Failed to open stream for url [/usr/share/elasticsearch/config/elasticsearch.yml]]; nested: AccessDeniedException[/usr/share/elasticsearch/config/elasticsearch.yml];
Likely root cause: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/config/elasticsearch.yml
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1067)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:88)
at org.elasticsearch.common.cli.CliTool.<init>(CliTool.java:107)
at org.elasticsearch.common.cli.CliTool.<init>(CliTool.java:100)
at org.elasticsearch.bootstrap.BootstrapCLIParser.<init>(BootstrapCLIParser.java:48)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:242)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
系統:
- 視窗10,具有VirtualBox的安裝,
- 一個的Xubuntu 16.04圖像,用含有Dockerfile一個共享主機的文件夾和elasticsearch.yml配置文件。
泊塢窗文件:
FROM openjdk:8-jre
ENV VERSION 2.4.1
RUN groupadd -r elasticsearch && useradd -r -g elasticsearch elasticsearch
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC8548582C1A2699A9D27D666CD88E42B4
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends apt-transport-https && rm -rf /var/lib/apt/lists/* \
&& echo 'deb http://packages.elasticsearch.org/elasticsearch/2.x/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends elasticsearch=$VERSION \
&& rm -rf /var/lib/apt/lists/*
ENV PATH /usr/share/elasticsearch/bin:$PATH
WORKDIR /usr/share/elasticsearch
RUN set -ex \
&& for path in \
./data \
./logs \
./config \
./config/scripts \
; do \
mkdir -p "$path"; \
chown -R elasticsearch:elasticsearch "$path"; \
done
COPY config ./config
VOLUME /usr/share/elasticsearch/data
VOLUME /usr/share/elasticsearch/logs
EXPOSE 9200 9300
USER elasticsearch
CMD elasticsearch
拋開Dockerfile,生活在以下文件結構:
- config
- elasticsearch.yml
作爲形象工程上的其他虛擬機,我相信它的配置應該是對的。我不認爲問題來自ElasticSearch,因爲我似乎有另一個圖像具有相同的問題(H2)。我是Docker和Linux的初學者級別。
謝謝。在複製工作後設置權限。不知道爲什麼它在我以前的虛擬機上工作,但現在很高興。乾杯。 – Elegie
從windows進入unix的權限映射總是有點搞砸。唯一可以信賴的地方在於它是一個linux文件系統,因此最好只在docker文件中設置所需的內容,這樣它就不會出錯。 – Matt