Noon
Noon

Reputation: 19

Docker build error /bin/sh: 1: apt-get: not found

i tried to build docker image but have this problem Here is my dockerfile

FROM ubuntu:16.04
MAINTAINER Noon [email protected]

RUN apt-get update && \ apt-get -y git 

CMD /bin/bash

Upvotes: 0

Views: 20228

Answers (4)

Fathi
Fathi

Reputation: 15

Using conda install -c anaconda git worked for me

Upvotes: 0

javaPlease42
javaPlease42

Reputation: 4963

A similar error could occur if you are on a different Unix distribution. In my case I changed apt-get to apk and that worked for me.

Upvotes: 1

Shahriar
Shahriar

Reputation: 13804

As @tgogos answered in comment, you can try

RUN apt-get update && apt-get install -y git

But if you want to use multi-line, you can also use like this

RUN apt-get update \
   && apt-get install -y git \
   && <other command under RUN> \
   && <and so on>

And @chepner is also right about multi-line style

Upvotes: 1

chepner
chepner

Reputation: 531135

The extraneous backslash is causing the space preceding apt-get to be treated literally, rather than just separating the command name from &&. The means you are trying to run a command named <space>apt-get. Just omit the backslash.

# And add the install command to the second call to apt-get
RUN apt-get update && apt-get install -y git

The backslash is only necessary if you want to split the RUN command across two lines, like

RUN apt-get update && \
apt-get install -y git

where the backslash acts as a line continuation in the Dockerfile; it's not part of the command itself.

Upvotes: 5

Related Questions