Ruby on rails 使用Dockerfile生成docker映像时出错

Ruby on rails 使用Dockerfile生成docker映像时出错,ruby-on-rails,docker,github,dockerfile,ubuntu-16.04,Ruby On Rails,Docker,Github,Dockerfile,Ubuntu 16.04,我正在尝试使用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 libp

我正在尝试使用
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
当我在bash中运行这些命令时,它们会按预期工作,但在docker构建期间不会:


有人能帮我找到解决方案吗?

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


这个版本应该有效。我刚刚将
git
添加到第一个
apt get install
步骤。

您需要安装
git
,基本的
ubuntu
image中没有提供它,我使用的是ubuntu16.0.4,它支持git:)
docker运行ubuntu:16.04 sh-c git
会给你同样的错误,因为它没有安装在提供的
ubuntu
图像中。你必须
安装git
,它才能工作。这是一个很好的技巧。我甚至不知道docker提供的ubuntu映像不提供git。非常感谢,你节省了我的时间:)
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
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