build context for docker image very large

后端 未结 10 872

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 t

10条回答
  •  Happy的楠姐
    2020-12-12 13:06

    Just to summarize what you can do if your Docker image build context too large:

    • make sure you don't have unused files in the context (unused files - those that still untouchable during image building);
    • add unused files and/or directories to .dockerignore (as mentioned here);
    • make sure you specify the right folder as an image build context (as mentioned here);
    • try to use BuildKit with DOCKER_BUILDKIT=1 (as mentioned here);
    • try to split your project into smaller parts to optimize content of build context;
    • if you have a complex project you may want to manually collect all necessary files in separate folder before build and use it as a build context for a specific image.

提交回复
热议问题