我正在尝试构建一个docker容器,但它似乎找不到我的start.sh。它将它复制到容器中,但它无论如何都不起作用。
这是我的dockerfile:
FROM ubuntu:16.04
# Install Meteor
RUN apt-get update
RUN apt-get install -y curl
RUN curl https://install.meteor.com/ | sh
RUN meteor npm install --save highcharts
# Entypointscript
COPY start.sh /
RUN chmod u+x /start.sh
# Copy App
COPY /app /app
# UI Expose
EXPOSE 80
ENTRYPOINT /start.sh
这是我的开始.sh:
#!/bin/bash
sleep 20
/app/meteor run
# don't exit
/usr/bin/tail -f /dev/null
此外,我不确定start.sh中的meteor run命令。如何告诉meteor run在特定目录中执行,而无法进入cd?
我正在使用Windows 10。 我将\ app \目录中的meteor应用程序和Dockerfile以及start.sh放在与app文件夹相同的目录中。
我使用:docker build -t meteorapp。
构建容器我尝试使用时出错:
docker run -p 80:80 --net docker-network --name meteorapp meteorapp
是:
/ bin / sh:1:/start.sh:not found
非常感谢!
答案 0 :(得分:4)
我也在Windows 10上运行,对我来说修复是将CR LF(windows)的行结尾更改为LF(Unix)。
我用Notepad ++做到了这一点,这让我很容易,现在我可以构建图像了。在"编辑" Notepad ++的菜单,你有" EOL转换"这完全符合你的需要。
答案 1 :(得分:0)
尝试将WORKDIR
添加到添加了start.sh的位置。例如:
WORKDIR /
ENTRYPOINT /start.sh
由于这不起作用,您可以尝试以下两件事:
1.由于您正在使用Windows,请确保start.sh的 EOL转换为UNIX
格式。
2.其次,将您的切入点更新为以下内容:
ENTRYPOINT ./start.sh
答案 2 :(得分:0)
Turns out there wasn't anything wrong with my files. I created a new directory on my pc, created new files and copied the contents of the start.sh and Dockerfile and my app there. The error was gone. This has to be some serious bug, my friend just got the same error with other files that work on my pc as well.
Maybe some issue with Docker and Windows 10.
EDIT: couldn't fix it for my friend and I run into the same issue again. Someone an idea how to fix?
SOLUTION: It is a incompatibility of the start.sh which is created under windows and with the one linux needs. To solve this, add this to the dockerfile, after you copied the start.sh:
RUN dos2unix /start.sh
If dos2unix is not installed, you have to install it first:
RUN apt-get install dos2unix