简体   繁体   中英

Error building docker image with Dockerfile

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

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:

 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?

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM