Reputation: 307
I have this Dockerfile, to which I am echoing the following line:
echo $"RUN cat file | while read pkg \
do\
sudo apt-get install -qy $pkg \
done" >> Dockerfile
Now, when docker executes this line, I get the following error:
/bin/sh: -c: line 1: syntax error: unexpected end of file
The command '/bin/sh -c cat autobuild/buildenv_packages | while read pkg do sudo apt-get install -qy done' returned a non-zero code: 1
I know there is something small and syntactical I am missing, but I am unable to figure it out. Notice that the $pkg
variable in the apt-get install
statement isn't in the error.
Any assistance would be appreciated!
Upvotes: 0
Views: 1361
Reputation: 530950
The backslashes in your code only prevent the string from containing literal newlines; they are not written to the Dockerfile
. Without a newline (or a semicolon) before do
, the while
condition never ends; you just have a giant list of arguments for the command read
.
echo 'RUN while read pkg; do sudo apt-get install -qy "$pkg"; done < file' >> Dockerfile
Upvotes: 3