0

My dockerfile is as below:

FROM bash:4.4
COPY prerequisites_ubuntu.sh   /temp/prerequisites_ubuntu.sh 
RUN  /temp/prerequisites_ubuntu.sh 

prerequisites_ubuntu.sh :

FROM ubuntu:latest

apt-get update  
apt-get install -y    coreutils  git-core ssh scons build-essential g++ libglib2.0-dev unzip uuid-dev python-dev autotools-dev gcc libjansson-dev cmake 

When I do docker build "docker build --rm --no-cache -t my_image ." It gives error as

/temp/prerequisites_ubuntu.sh: line 1: FROM: not found
/temp/prerequisites_ubuntu.sh: line 3: apt-get: not found
/temp/prerequisites_ubuntu.sh: line 4: apt-get: not found

The prerequisites_ubuntu.sh file will change for RaspberryPI or other platform

4
  • Add a shebang to your bash script. FROM is no bash command. Commented Jun 21, 2019 at 8:15
  • 1
    The image bash:4.4 not have FROM command and also not have apt, prerequisites_ubuntu.sh not a valid bash file. Commented Jun 21, 2019 at 8:16
  • Sorry, can't catch your point, I deleted my answer. Commented Jun 21, 2019 at 8:32
  • I have updated my comment @atline could you please comment Commented Jun 21, 2019 at 9:01

1 Answer 1

1

There are a couple of issues with the prerequisites_ubuntu.sh file. First of all, it is not an sh file. You are missing a shebang (which specifies which shell to use to execute the script). the FROM statement is part of the Dockerfile spec, not of shell scripts (which is why you get FROM: not found) as an error. And the bash image is based on alpine linux, which does not use apt-get but it uses apk add. Once you change the shell script to use apk add, add a shebang, and remove the FROM statement it should work.

Sign up to request clarification or add additional context in comments.

7 Comments

My task is that I should run a simple script prerequisites_ubuntu.sh or prerequisite_rpi.sh which should install base image and dependant packages . The script to be run is chosen based on user input on the platform used . I have to use FROM bash else it will not allow me to do RUN inside dockerfile. How could I probably achieve this
Maybe it is good to specify in your question what exactly you want to achieve. Do you want to use this dockerfile to install a raspbarry py?
I want to run prerequisites code on ubuntu-Linux and Raspberry PI– arm linux platform.Base image cannot be ubuntu in both the platforms as far as I know. Please correct. Therefore I want to run bash script at the beginning to choose the base image. Hence the question
The whole point of Docker is that you can run the same code on irrespective of the underlying OS (with some quirks), but it seems as if your goal is to install the packages on the underlying OS, which might be a bit more involved. You are currently installing the packages on the docker image when you call RUN.
So I can use the base image same and install dependant packages based on the Hardware I want to run the docker image .
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.