Docker:无法访问基于镜像的文件夹结构



我有这张图片:

FROM ubuntu:14.04.3
# copy db project to container
ADD . /db_project
WORKDIR /db_project
CMD ["./gitinitall.sh"]

这将使用包含 git 子模块的 dit 子模块复制当前目录的内容,该项目将签出并从存储库中提取。因此,db_project是我运行以获取子模块的 shell 脚本。还具有使用数据库的后端。映像将推送到专用存储库。

我想使用此映像创建一个容器,我需要在其中为需要部署数据库的环境添加数据库的配置,如下所示:

FROM myprivatedockerrepo:5000/db_project
...
WORKDIR /db_project
COPY config/dev.config /db_project/apps/mydb_db/config/dev.config
# get everything needed for backend
RUN mix deps.get
# expose the backend port
EXPOSE backendport
# start the beckend with the proper db configured
CMD ["./startbeckend"]

但它无法运行混合deps.get:

Step 14/20 : RUN mix deps.get
---> Running in ab7375d69989
warning: path "apps/mydb_db" is a directory but it has no mix.exs. Mix won't consider this directory as part of your umbrella application. Please add a "mix.exs" or set the ":apps" key in your umbrella configuration with all relevant apps names as atoms

如果我添加一个

RUN ls apps/mydb_db  

在运行 mix 命令之前:

ls: cannot access apps/mydb_db: No such file or directory 

所以看起来虽然在使用的图像中,myprivatedockerrepo:5000/db_project,应该有db_project/apps/mydb_db - 由 shell 脚本子模块从 git 获取mydb_db创建,它找不到它,也许我不了解 docker 层什么的?

要复制文件夹,您需要添加最终的"/">

# Dockerfile 加。/db_project/

另请参阅此处:https://docs.docker.com/engine/reference/builder/#add

是我的坏,从 Git 获取和更新所有子模块的 gitinitall.sh 脚本不起作用,因为映像中没有 Git 设置或 SSH 密钥,但它没有返回任何代码,因此没有显示失败。

最新更新