我正在docker容器中运行elasticsearch。图像的Dockerfile如下所示:
# Dockerfile.ruby-2.4.1-elasticsearch-1.4.4
FROM ruby:2.4.1
# Install Java 8
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \
apt-get update && \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y oracle-java8-installer && \
apt-get clean
# Download and unpack elasticsearch 1.4.4
RUN wget -q -O elasticsearch-1.4.4.tar.gz https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz && \
tar -xzf elasticsearch-1.4.4.tar.gz && \
mv elasticsearch-1.4.4 $HOME/.elasticsearch && \
ln -s $HOME/.elasticsearch/bin/elasticsearch /usr/local/bin/elasticsearch && \
mkdir -p /usr/local/share/elasticsearch/ && \
cp $HOME/.elasticsearch/bin/elasticsearch.in.sh /usr/local/share/elasticsearch/ && \
rm elasticsearch-1.4.4.tar.gz
建造时
docker build - < .gitlab-ci/Dockerfile.ruby-2.4.1-elasticsearch-1.4.4 -t hirurg103/ruby-2.4.1-elasticsearch-1.4.4
并启动交互式bash会话
docker run -i -t hirurg103/ruby-2.4.1-elasticsearch-1.4.4 bash
并在我得到的容器中运行elasticsearch --version
/usr/local/bin/elasticsearch: 168: shift: can't shift that many
第168行的elasticsearch bin脚本的外观如下:
...
# Parse any long getopt options and put them into properties before calling getopt below
# Be dash compatible to make sure running under ubuntu works
ARGV=""
while [ $# -gt 0 ]
do
case $1 in
--*=*) properties="$properties -Des.${1#--}"
shift 1
;;
--*) properties="$properties -Des.${1#--}=$2"
shift 2
;;
*) ARGV="$ARGV $1" ; shift
esac
done
...
当我开始我的rspec测试时,它们会出现实际问题,并且会因
而失败/usr/local/bin/elasticsearch: 168: shift: can't shift that many
rake aborted!
Cannot determine Elasticsearch version from [elasticsearch --version] or [elasticsearch -v]
正在从elasticsearch-extensions
ruby gem调用 elasticsearch --version
此脚本有什么问题?如何解决此错误?
我的本地计算机Mac OS 10.14.1 Mojave
和zsh 5.6.2
上的BTW运行顺利
答案 0 :(得分:0)
目前,我能够通过在初始化Elasticsearch::Extensions::Test::Cluster
时直接指定elasticsearch版本来解决此错误:
require 'elasticsearch/extensions/test/cluster'
Elasticsearch::Extensions::Test::Cluster.start(
port: 9250,
version: '1.0'
)