Host with Ubuntu 16.04.2.
Docker version 17.06.0-ce.
Dockerfile
RUN echo -e "deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx\ndeb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx" | tee /etc/apt/sources.list.d/nginx.list
This results in in /etc/apt/sources.list.d/nginx.list:
-e deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
Well, as if interpretation of backslash escapes works. But this "-e" has occurred in the file.
And then such image can't be built.
Could you give me a kick here?
Try using the bash shell
for the echo
command instead. Docker by default uses the sh
shell and for some reason it doesn't like the -e
characters and had echo'ed it as part of its input.
To fix this;
Update to:
RUN bash -c 'echo -e "deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx\ndeb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx" | tee /etc/apt/sources.list.d/nginx.list'
Outputs:
root@87944d07f493:/etc/apt/sources.list.d# cat nginx.list deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
You can replicate this "docker problem" by switching to sh
on your current terminal session and then do the same echo
command again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With