与Docker一起复制但不包含复制 [英] COPY with docker but with exclusion

查看:159
本文介绍了与Docker一起复制但不包含复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Dockerfile中,我有

In a Dockerfile, I have

COPY . .

我想排除整个目录,例如我的node_modules目录.

I want to exclude an entire directory, in my case, node_modules directory.

类似这样的东西:

   COPY [all but **/node_modules/**] .

使用Docker是否可能?

Is this possible with Docker?

推荐答案

在docker build上下文目录(因此,在这种情况下,很可能是node_modules的父目录)中创建文件.dockerignore :

Create file .dockerignore in your docker build context directory (so in this case, most likely a directory that is a parent to node_modules) with one line in it:

**/node_modules

尽管您可能只想要:

node_modules

有关dockerignore的信息: https://docs.docker.com/engine/reference/builder/#dockerignore-file

Info about dockerignore: https://docs.docker.com/engine/reference/builder/#dockerignore-file

这篇关于与Docker一起复制但不包含复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆