【发布时间】:2017-07-02 03:51:57
【问题描述】:
我是 docker 新手,正在尝试将应用程序移植到它。本质上,在启动时,应用程序需要执行一些我已封装在脚本中的环境相关工作。
我的应用看起来像
Dockerfile
scripts/run.sh
build-development/stuff
build-production/stuff
这是我的 Dockerfile:
FROM nginx
RUN chmod +x scripts/run.sh
CMD ["scripts/run.sh", APP_ENV]
EXPOSE 80
这里是scripts/run.sh:
#!/bin/bash
mkdir dist
chmod -R 777 dist
if [ $1 == "development" ]
then
cp -R build-development/. /usr/share/nginx/html
fi
if [ $1 == "stage" ]
then
cp -R build-production/. /usr/share/nginx/html
sed -i 's/production/stage/g' dist/index.html
fi
if [ $1 == "production" ]
then
cp -R build-production/. /usr/share/nginx/html
fi
我的想法是我会像这样运行图像:
docker run -e APP_ENV=development app-name
它将被输入到脚本中,该脚本将复制正确的文件。
不幸的是,我永远无法运行映像,因为在构建步骤中:
docker build -t app-name .
我收到关于
的错误scripts/run.sh 不是文件或目录
我不明白为什么我会收到这个错误,我想这是我天真的误解造成的。我做错了什么,我怎样才能让我的项目工作?
提前致谢。
【问题讨论】:
标签: docker