Docker镜像无法运行

时间:2017-08-23 11:07:04

标签: docker

我已经构建了一个docker镜像,现在在尝试运行容器时,我收到以下错误消息:

$ docker run myimage
[dumb-init] /docker-entrypoint.sh: No such file or directory

有什么想法吗?

图像上还存在文件docker-entrypoint.sh

$ docker run --entrypoint=/bin/ls myimage -l /docker-entrypoint.sh
-rwxr-xr-x 1 root root 724 Aug 23 09:50 /docker-entrypoint.sh


FROM ubuntu:16.04
MAINTAINER Gareth Rushgrove "gareth@puppet.com"

ARG ssh_prv_key
ARG ssh_pub_key

ENV PUPPET_SERVER_VERSION="2.7.2" DUMB_INIT_VERSION="1.1.0" UBUNTU_CODENAME="xenial" PUPPETSERVER_JAVA_ARGS="-Xms256m -Xmx256m" PATH=/opt/puppetlabs/server/bin:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin:$PATH

LABEL org.label-schema.vendor="Puppet" \
      org.label-schema.url="https://github.com/puppetlabs/puppet-in-docker" \
      org.label-schema.name="Puppet Server (No PuppetDB)" \
      org.label-schema.license="Apache-2.0" \
      org.label-schema.version=$PUPPET_SERVER_VERSION \
      org.label-schema.vcs-url="https://github.com/puppetlabs/puppet-in-docker" \
      org.label-schema.vcs-ref="a2b1fbbc73177ddc3def23d167f9beb9c3ef9f6c" \
      org.label-schema.build-date="2017-02-21T17:25:14Z" \
      org.label-schema.schema-version="1.0" \
      com.puppet.dockerfile="/Dockerfile"

RUN apt-get update && \
    apt-get install -y wget=1.17.1-1ubuntu1 git && \
    wget https://apt.puppetlabs.com/puppetlabs-release-pc1-"$UBUNTU_CODENAME".deb && \
    wget https://github.com/Yelp/dumb-init/releases/download/v"$DUMB_INIT_VERSION"/dumb-init_"$DUMB_INIT_VERSION"_amd64.deb && \
    dpkg -i puppetlabs-release-pc1-"$UBUNTU_CODENAME".deb && \
    dpkg -i dumb-init_"$DUMB_INIT_VERSION"_amd64.deb && \
    rm puppetlabs-release-pc1-"$UBUNTU_CODENAME".deb dumb-init_"$DUMB_INIT_VERSION"_amd64.deb && \
    apt-get update && \
    apt-get install --no-install-recommends -y puppetserver="$PUPPET_SERVER_VERSION"-1puppetlabs1 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    gem install --no-rdoc --no-ri r10k

COPY puppetserver /etc/default/puppetserver
COPY logback.xml /etc/puppetlabs/puppetserver/
COPY request-logging.xml /etc/puppetlabs/puppetserver/

RUN puppet config set autosign true --section master

VOLUME /etc/puppetlabs/code/ \
       /etc/puppetlabs/puppet/ssl/ \
       /opt/puppetlabs/server/data/puppetserver/

COPY docker-entrypoint.sh /


# Add the keys and set permissions
RUN mkdir -p /root/.ssh && \
    chmod 0700 /root/.ssh && \
    echo "$ssh_prv_key" > /root/.ssh/id_rsa && \
    echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub && \
    chmod 600 /root/.ssh/id_rsa && \
    chmod 600 /root/.ssh/id_rsa.pub && \
    echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config


EXPOSE 8140

ENTRYPOINT ["dumb-init", "/docker-entrypoint.sh"]
CMD ["foreground" ]

COPY Dockerfile /

1 个答案:

答案 0 :(得分:0)

文件docker-entrypoint.sh不是图像的一部分,但它在Dockerfile中定义。

使用“Dockerfile”创建图像时,此文件将复制到图像中。

你可以在github上看到mysql的例子。

https://github.com/docker-library/mysql/tree/master/5.6

您可以使用以下命令将Dockerfile用于构建的映像

docker build -t mysql -f Dockerfile .

你将使用此命令运行图像,无需在运行命令中定义为入口点

docker run --name mysql

在Dockerfile中

ENV STARTUP_SCRIPT=/usr/local/bin/start-up.sh

COPY nginx/start-up.sh $STARTUP_SCRIPT

ENTRYPOINT $STARTUP_SCRIPT