Ruby Dockerfile - 无法使用Dockerfile

时间:2018-06-19 10:03:50

标签: docker elasticsearch dockerfile

我试图将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

请帮忙吗?

0 个答案:

没有答案
相关问题