Dockerfile拆分
我的python文件夹结构如下
|_ _ helper |_ _ Action1 |_ _ Action2 Action1 and Action2 use helper package .
我想要做如下分割的dockerfile
Docker file Base -> which contains common packages like pika which are necessary to build Action1 and Action2 Individual docker file images -> Individual docker file for Action1 and Action2 modules.
由于我无法在Action1和Action2中执行cd ..因为每当构builddockerfile时,都会将docker上下文发送到守护程序。
请build议如何继续上述
在docker build
命令中,您可以指定哪个文件夹是您的根文件夹(上下文) – 这是以下示例中的最后一个参数../
。
假设您的dockerfile在Action1
文件夹和您的当前工作目录Action1
您可以运行:
~/Action1# docker build -f dockerfile -t <image_name> ../
注意/提示:您可以在父目录中添加.dockerignore
文件,以减less.dockerignore
将内容加载到内存中的时间(如果父目录太大。
祝你好运!