17

I want to copy some files to my images and I wan to use the ADD command. I read in the Docker documentation about regular expression for ADD, but I don't know what kind of expression can I use?

I want something like this

FROM registry:5000/ubuntu:14.04
MAINTAINER Me

# some stuffs 

ADD Sources/{file1,file2,load_file} /etc/Sources/

# more stuffs

Note: the expression is wrong but I did it to show you what I expect from the ADD command. (I did it thinking in shell regular expressions).

So, How can I do that? I can not access to the link filepath.Match. If anyone have these rules, please let me know?

Update

I am using this Docker docs reference

I am using this version:

Client version: 1.3.0
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): c78088f
OS/Arch (client): linux/amd64
Server version: 1.3.0
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): c78088f
1
  • 1
    could you link to the documentation bit that describes the usage of regex for the ADD instruction? Commented Oct 27, 2014 at 18:58

4 Answers 4

36

The ADD command and COPY both allow Golang's filepath.Match wildcards

You can find a number of examples in the test code for Go: https://golang.org/src/pkg/path/filepath/match_test.go

Rules reproduced here for those in China who can't access Google/golang.org:

    '*'         matches any sequence of non-Separator characters
    '?'         matches any single non-Separator character
    '[' [ '^' ] { character-range } ']'
                character class (must be non-empty)
    c           matches character c (c != '*', '?', '\\', '[')
    '\\' c      matches character c

character-range:
    c           matches character c (c != '\\', '-', ']')
    '\\' c      matches character c
    lo '-' hi   matches character c for lo <= c <= hi
Sign up to request clarification or add additional context in comments.

Comments

5

Usually, you would end up putting all the relevant files into a sub-directory, and then just ADD that directory, to bring them into the image.

1 Comment

I want to add the only specific files, I don't want to ADD the all directory :(
2

Example how add files with ext .so to directory:

ADD modules/*.so /usr/local/apache2/modules/

or you can add all files in directory

ADD modules/* /usr/local/apache2/modules/

Comments

0

Please notice that in ADD you can provide an url. And in url you won't be able to do something like:

ADD http://myStorage.com/something/*.jar /dir1/dirb

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.