使用Dockerfile构建docker镜像时出错

时间:2022-03-12 23:40:00

I’m trying to build docker image with a configuration in Dockerfile:

我正在尝试使用Dockerfile中的配置构建docker镜像:

FROM ubuntu
MAINTAINER axiom88guru(axiom88guru@gmail.com)
Configuration for app below.
Run upgrades

RUN apt-get update
Install basic packages

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
Install Ruby

RUN apt-get -qq -y install ruby-full
RUN gem install bundler --no-ri --no-rdoc
RUN gem install foreman
Install rails-new-docker

WORKDIR /app
RUN git clone https://github.com/axiom88-guru/rails-docker.git /app
RUN bundle install --without development test
Run rails-new-docker

ENV SECRET_KEY_BASE dockerkeybase
ENV RAILS_ENV production
EXPOSE 5959
CMD foreman start -f Procfile

When I run these commands in bash they work as expected, but not during docker build:

当我在bash中运行这些命令时,它们按预期工作,但在docker build期间不能:

Removing intermediate container 344e99851852
Step 8/14 : WORKDIR /app
—> 3c204a395f23
Removing intermediate container 680b1841a3fc
Step 9/14 : RUN git clone https://github.com/axiom88-guru/rails-docker.git /app
—> Running in d7a9de9f6ab5
/bin/sh: 1: git: not found
The command ‘/bin/sh -c git clone https://github.com/axiom88-guru/rails-docker.git /app’ returned a non-zero code: 127

Could anyone help me find out the solution please?

谁能帮我找到解决方案呢?

1 个解决方案

#1


1  

Need to have git installed since the base ubuntu image provides only a minimal set of installed packages (this is done to keep image size small).

需要安装git,因为基本的ubuntu映像只提供了一组最小的安装包(这样做是为了保持图像大小很小)。

FROM ubuntu
MAINTAINER axiom88guru(axiom88guru@gmail.com)
# Configuration for app below.
# Run upgrades

RUN apt-get update
# Install basic packages

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs git
# Install Ruby

RUN apt-get -qq -y install ruby-full
RUN gem install bundler --no-ri --no-rdoc
RUN gem install foreman
# Install rails-new-docker

WORKDIR /app
RUN git clone https://github.com/axiom88-guru/rails-docker.git /app
RUN bundle install --without development test
# Run rails-new-docker

ENV SECRET_KEY_BASE dockerkeybase
ENV RAILS_ENV production
EXPOSE 5959
CMD foreman start -f Procfile

This version should work. I just added git to the first apt-get install step.

这个版本应该工作。我刚刚将git添加到第一个apt-get安装步骤中。

#1


1  

Need to have git installed since the base ubuntu image provides only a minimal set of installed packages (this is done to keep image size small).

需要安装git,因为基本的ubuntu映像只提供了一组最小的安装包(这样做是为了保持图像大小很小)。

FROM ubuntu
MAINTAINER axiom88guru(axiom88guru@gmail.com)
# Configuration for app below.
# Run upgrades

RUN apt-get update
# Install basic packages

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs git
# Install Ruby

RUN apt-get -qq -y install ruby-full
RUN gem install bundler --no-ri --no-rdoc
RUN gem install foreman
# Install rails-new-docker

WORKDIR /app
RUN git clone https://github.com/axiom88-guru/rails-docker.git /app
RUN bundle install --without development test
# Run rails-new-docker

ENV SECRET_KEY_BASE dockerkeybase
ENV RAILS_ENV production
EXPOSE 5959
CMD foreman start -f Procfile

This version should work. I just added git to the first apt-get install step.

这个版本应该工作。我刚刚将git添加到第一个apt-get安装步骤中。