this is my vagrant file
Vagrant.configure("2") do |config|
config.vm.define "app" do |app|
app.vm.provider "docker" do |d|
d.build_dir = "."
d.cmd = ["/sbin/my_init", "--enable-insecure-key"]
end
end
config.ssh.username = "root"
config.ssh.private_key_path = "insecure_key"
end
This is my docker file
FROM phusion/baseimage:0.9.15
MAINTAINER neetu
ENV HOME /root
RUN mkdir /buzzbuild
ADD . /buzzbuild
RUN cd /buzzbuild/ && chmod 777 install.sh && sh install.sh
CMD ["/sbin/my_init"]
EXPOSE 80 443 5000 15672
so as you can see .. 1) i am adding my buidl directory(.) to /buzzbuild 2) and am running a install script there (after i CD into that dir)
and i get
root@8bde177d1bc2:/buzzbuild# ./test2.sh -bash: ./install.sh: /bin/sh^M: bad interpreter: No such file or directory
the contents of the install script are :-
#!/bin/sh
#apt-get update
apt-get update
apt-get install -y -q git
If i create new file (test.sh) adn change permissions on it and add the same content it works.
but the install.sh script does not work.
I suspect its a problem of files getting added from windows to ubuntu(container)
any suggestions ?
The error message root@8bde177d1bc2:/buzzbuild# ./test2.sh -bash: ./install.sh: /bin/sh^M: bad interpreter: No such file or directory
gives you a hint that your install.sh file has Windows style end of lines.
Windows end of lines are made of two characters: \\r\\n
while Linux end of lines are just \\n
. ^M
represents the \\r
character in the error message.
Either make sure all your scripts are using Linux style end of line before building your image or in your Dockerfile add a RUN statement that fixes end of lines:
ADD . /buzzbuild
RUN cd /buzzbuild/ \
&& sed -i 's/\r//' install.sh \
&& chmod 777 install.sh \
&& sh install.sh
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.