对Docker图像的构建环境非常大 [英] build context for docker image very large
问题描述
FROM crystal / centos
维护水晶
ADD ./rpms/test.rpm ./rpms/
RUN yum -y --nogpgcheck localinstall /rpms/test.rpm
我的实际rpm只有1 GB。但是当我尝试执行 sudo docker build -t =crystal / test时,我发送构建上下文到Docker守护进程3.5 GB。有没有什么我不知道,因为你继续构建Docker图像?当我在主机上的其他目录中构建更多图像时,我的内存是否累积?
Docker客户端将整个构建上下文发送到Docker守护程序。该构建上下文(默认情况下)是 Dockerfile
所在的整个目录(因此,整个 rpms
树)。
您可以设置 .dockerignore
文件让Docker忽略一些文件。您可能需要尝试一下。
或者,您可以将 rpms
code> Dockerfile ,只有符号链接 test.rpm
到 Dockerfile
s目录。
I have created a couple different directories on my host machine as I try to learn about Docker just to keep my dockerfiles organized. My Dockerfile I just ran looks like this:
FROM crystal/centos
MAINTAINER crystal
ADD ./rpms/test.rpm ./rpms/
RUN yum -y --nogpgcheck localinstall /rpms/test.rpm
My actual rpm is only 1 GB. But when I try to do sudo docker build -t="crystal/test" .
, I get sending build context to Docker daemon 3.5 GB. Is there something else that I'm unaware of as you continue to build Docker images? Is my memory accumulating as I build more images in my other directories on my host machine?
The Docker client sends the entire "build context" to the Docker daemon. That build context (by default) is the entire directory the Dockerfile
is in (so, the entire rpms
tree).
You can setup a .dockerignore
file to get Docker to ignore some files. You might want to experiment with it.
Alternatively, you can move your rpms
folder one directory level above your Dockerfile
, and only symlink test.rpm
into the Dockerfile
's directory.
这篇关于对Docker图像的构建环境非常大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!