Logstash在泊坞窗 - 配置文件,虽然安装卷时未找到 [英] Logstash in Docker - config file not found when mounted though a volume
问题描述
编辑:这似乎是一个boot2docker的事情...在Ubuntu的虚拟机中运行码头工人正常工作
。我想火起来logstash在泊坞容器,但是当我安装配置文件作为卷,它似乎并没有找到它。有趣的是,如果我开始了使用bash容器,我可以看到在那里的配置文件,并运行相同的命令,什么泊坞窗会,它的工作原理。
泊坞文件
从Ubuntu:14.04
MAINTAINER cvallance运行apt-get更新
运行apt-get -yqq安装的OpenJDK 7的JRE
运行apt-get -yqq安装卷曲
RUN的mkdir /选择/ logstash \\
&功放;&安培; CD /选择/ logstash \\
&功放;&安培;卷曲-O https://download.elastic.co/logstash/logstash/logstash-1.4.2.tar.gz \\
&功放;&安培;焦油zxvf logstash-1.4.2.tar.gzCMD [/opt/logstash/logstash-1.4.2/bin/logstash,代理,--verbose,F,/etc/logstash/sample.conf]
/config/sample.conf位于 $(PWD)的配置文件
输入{
标准输入{}
}输出{
标准输出{
codeC => rubydebug
}
}
泊坞建造的命令:
泊坞窗打造-t cvallance / logstash。
泊坞窗运行命令:
泊坞窗运行-ti -v $(PWD)/配置:在/ etc / logstash cvallance / logstash
错误:
错误:未找到配置文件:/etc/logstash/sample.conf
你可以确保这个路径是logstash配置文件?
BUT 如果我从一个bash会话中运行的容器内的同一个命令是这样的...
泊坞窗运行-ti -v $(PWD)/配置:在/ etc / logstash cvallance / bash的logstash
...
根@ d3fd885903dd:/#/opt/logstash/logstash-1.4.2/bin/logstash剂--verbose -f /etc/logstash/sample.conf
一切正常。即输入和输出
测试
{
消息=> 测试,
@version=> 1,
@timestamp=> 2015-04-10T00:06:33.878Z,
主持人=> d3fd885903dd
}
如果它是一个boot2docker的事情,记得是为您提供基于微内核Linux主机,的 无任何持久性 (除的/ var / lib中/泊坞窗
)。
我做的是确保 Oracle_VM_VirtualBox_Extension_Pack 的安装,并让我的 / C /用户/< yourLogin>
在我boot2docker SSH会话自动共享结果。
无论我需要保持有写( / C /用户/< yourLogin> / ...
),而不是其他任何地方搜索
如果你有安装一个主机目录作为数据量,应安装在 / C /用户/℃的文件夹; yourLogin> / ...
。
的其它选项(确实仍然存在)是定义一个<一href=\"https://docs.docker.com/userguide/dockervolumes/#creating-and-mounting-a-data-volume-container\"相对=nofollow>数据卷集装箱,这将在 /var/lib/docker/volumes/conf.json
,以及(实际文件)的/ var / lib中/泊坞窗/ VFS / XXX
。结果
这是preferred最佳做法,因为它不会将您的数据容器链接到一个特定的主机平台(这里 / C /用户/&LT; yourLogin&GT;
实际上要看的 VM 的主机,在Windows!不是很便携。)
EDIT: It seems to be a boot2docker thing... works fine in an ubuntu vm running docker.
I'm trying to fire up logstash in a Docker container but when I mount the config file as a volume, it doesn't seem to find it. Interestingly, if I start up the container with bash, I can see the config file in there and running the same command as what docker would, it works.
Docker File
FROM ubuntu:14.04
MAINTAINER cvallance
RUN apt-get update
RUN apt-get -yqq install openjdk-7-jre
RUN apt-get -yqq install curl
RUN mkdir /opt/logstash \
&& cd /opt/logstash \
&& curl -O https://download.elastic.co/logstash/logstash/logstash-1.4.2.tar.gz \
&& tar zxvf logstash-1.4.2.tar.gz
CMD ["/opt/logstash/logstash-1.4.2/bin/logstash", "agent", "--verbose", "-f", "/etc/logstash/sample.conf"]
Config file located at $(pwd)/config/sample.conf
input {
stdin { }
}
output {
stdout {
codec => rubydebug
}
}
Docker build command:
docker build -t cvallance/logstash .
Docker run command:
docker run -ti -v $(pwd)/config:/etc/logstash cvallance/logstash
Error:
Error: No config files found: /etc/logstash/sample.conf
Can you make sure this path is a logstash config file?
BUT if I run the same command inside the container from a bash session like so...
docker run -ti -v $(pwd)/config:/etc/logstash cvallance/logstash bash
...
root@d3fd885903dd:/# /opt/logstash/logstash-1.4.2/bin/logstash agent --verbose -f /etc/logstash/sample.conf
Everything works as expected. I.e. input and output
testing
{
"message" => "testing",
"@version" => "1",
"@timestamp" => "2015-04-10T00:06:33.878Z",
"host" => "d3fd885903dd"
}
If it is a "boot2docker" thing, remember that is offers you a Linux host based on Tiny core, without any persistence (except /var/lib/docker
).
What I do is make sure the Oracle_VM_VirtualBox_Extension_Pack is installed, and get my /c/Users/<yourLogin>
automatically shared in my boot2docker ssh session.
Whatever I need to keep is written there (/c/Users/<yourLogin>/...
), not anywhere else.
If you have to mount a host directory as a data volume, you should mount a folder from /c/Users/<yourLogin>/...
.
The other option (which does persists) is to define a Data Volume Container, which will persists data in /var/lib/docker/volumes/conf.json
, and (for the actual files) in /var/lib/docker/vfs/xxx
.
That is the preferred best-practice as it doesn't link your data container to a specific host platform (here '/c/Users/<yourLogin>
actually depends on the VM host, on Windows! Not very portable.)
这篇关于Logstash在泊坞窗 - 配置文件,虽然安装卷时未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!