docker build前耗时太长,不明所以

前言

在构建镜像时发现明明没基础镜像没那么大,却一直在加载什么东西,直至到了一个点,搜索发现是因为Docker Client会默认发送Dockerfile同级目录下的所有文件到Dockerdaemon中,是因为当前目录下环境太杂,文件太多

关键内容

root@ez \~\]# docker build -f Dockerfile_nginx -t erp_nginx:v1.1.0 . DEPRECATED: The legacy builder is deprecated and will be removed in a future release. Install the buildx component to build images with BuildKit: https://docs.docker.com/go/buildx/ Sending build context to Docker daemon 9.918GB Step 1/9 : FROM nginx:latest ---\> 39286ab8a5e1 \[root@ez \~\]# du -sh . #查看当前路径大小 9.3G .

解决方法有两种:

1.创建.dockerignore文件,把不需要的文件写到里面,该文件包含的目录不会被发送到Docker daemon中
2.就找个空目录只有dockerfile。

源作者地址:

解决Docker build时 Sending build context to Docker daemon 过大的问题 _51CTO博客_docker build 失败

相关推荐
shixian10304117 小时前
Dify Docker Compose 安装指南
docker·容器·eureka
Fcy6487 小时前
Linux下的项目自动化构建-make\makefile详解
linux·运维·自动化·makefile·make
曦樂~7 小时前
【Docker】Compose
docker·容器·eureka
加上音乐7 小时前
windows—wsl2—docker配置代理以push/pull
windows·docker·容器
keep__go7 小时前
zookeeper单机版安装
大数据·运维·zookeeper
chde2Wang7 小时前
Linux中bash: ls: 未找到命令… 相似命令是: ‘lz‘
linux·运维·bug·bash
楼田莉子8 小时前
Linux学习:进程的控制
linux·运维·服务器·c语言·后端·学习
捷智算云服务8 小时前
H100服务器维修“病历卡”:五大常见故障现象与根源分析
运维·服务器
wzlsunice888 小时前
用vir-manager创建kvm虚拟机(创建网桥和配置网络等)
运维·网络
南方以南_9 小时前
CKA07--Argo CD
运维·kubernetes·k8s