tony.zheng
tony.zheng

Reputation: 41

Dockerignore: Ignore everything except a folder

I want to ignore all the folders in src/modules except mall folder when build images. I try like below, but it doesn't work.

src/modules
!src/modules/mall

Any help will be appreciated.

Upvotes: 4

Views: 4933

Answers (2)

RailTracer
RailTracer

Reputation: 88

Try using wildcards, and both for exclusions and inclusions in this case.

Also, .dockerignore supports ** wildcards for any number of directories depth like go does.

So try this:

src/modules/**
!src/modules/mall/**

Reference

If this doesn't work, could you elaborate in what doesnt work?

Upvotes: 4

jonhid
jonhid

Reputation: 2135

Do it like this

src/modules/*
!src/modules/mall

Upvotes: 1

Related Questions