docker - Ruby Dockerfile - 无法使用 Dockerfile 在 Ruby 映像中安装和配置 elasticsearch
问题描述
我正在尝试将 java 8 和 elasticsearch 安装到我的 ruby 图像中。
添加我通常在手动配置时使用的配置会导致错误并且总是失败。
然后我尝试添加java和elasticsearch最新官方docker镜像中使用的配置。
我的 Dockerfile 现在如下:
FROM ruby:2.5
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
mysql-client
RUN apt-get install -y software-properties-common
# add a simple script that can auto-detect the appropriate JAVA_HOME value
# based on whether the JDK or only the JRE is installed
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ENV JAVA_VERSION 8u111
# see https://bugs.debian.org/775775
# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
RUN set -x \
&& apt-get update \
&& apt-get install -y \
openjdk-8-jdk \
ca-certificates-java \
&& rm -rf /var/lib/apt/lists/* \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]
# see CA_CERTIFICATES_JAVA_VERSION notes above
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
ENV GOSU_VERSION 1.10
RUN set -x \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)"
RUN wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc"
RUN export GNUPGHOME="$(mktemp -d)"
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu
RUN rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc
RUN chmod +x /usr/local/bin/gosu
RUN gosu nobody true
RUN set -ex; \
# https://artifacts.elastic.co/GPG-KEY-elasticsearch
key='46095ACC8548582C1A2699A9D27D666CD88E42B4'; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
gpg --export "$key" > /etc/apt/trusted.gpg.d/elastic.gpg; \
rm -rf "$GNUPGHOME"; \
apt-key list
# https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
# https://www.elastic.co/guide/en/elasticsearch/reference/5.0/deb.html
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends apt-transport-https && rm -rf /var/lib/apt/lists/* \
&& echo 'deb https://artifacts.elastic.co/packages/5.x/apt stable main' > /etc/apt/sources.list.d/elasticsearch.list
ENV ELASTICSEARCH_VERSION 5.6.9
ENV ELASTICSEARCH_DEB_VERSION 5.6.9
RUN set -x \
# don't allow the package to install its sysctl file (causes the install to fail)
# Failed to write '262144' to '/proc/sys/vm/max_map_count': Read-only file system
&& dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \
&& apt-get update \
&& apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_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
RUN rm -rf /var/lib/apt/lists/*
ENV INSTALL_PATH /my_app
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY Gemfile Gemfile
RUN bundle install
COPY . .
RUN bundle exec rake RAILS_ENV=production DATABASE_URL=mysql://username:password@127.0.0.1:3306/database_name SECRET_TOKEN=sometoken assets:precompile
VOLUME ["$INSTALL_PATH/public"]
CMD bundle exec unicorn -c config/unicorn.rb
但是,现在我被困在弹性搜索中。当我到达时,RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
我得到以下信息:
gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: keyserver receive failed: Cannot assign requested address
The command '/bin/sh -c gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4' returned a non-zero code: 2
请问有什么帮助吗?
解决方案
推荐阅读
- php - 我的脚本上的内爆错误
- c# - Discord.net 无法添加“数字”表情符号反应
- reactjs - React 中的 DOM 突变警告
- c++ - 强制转换 std::list
到 std::list - javascript - 为什么 jQuery prependTo 会复制我正在移动的元素?
- git - Windows 上的接收后挂钩和 Jenkins
- gwt - SuperDevMode 未获取 webapp 目录中 CSS 和 HTML 文件的更改
- python - 使用该键,删除所有具有相似值的键
- python - PyQt5:尝试从服务器监听,但错误提示未定义 client_socket
- c# - 如何调整通知图标的大小?