How to copy folders to docker image from Dockerfile?

后端 未结 10 649
走了就别回头了
走了就别回头了 2021-01-31 01:41

I tried the following command in my Dockerfile: COPY * / and got mighty surprised at the result. Seems the naive docker code traverses the directories from the glob

相关标签:
10条回答
  • 2021-01-31 02:29

    Like @Vonc said, there is no possibility to add a command like as of now. The only workaround is to mention the folder, to create it and add contents to it.

    # add contents to folder
    ADD src $HOME/src
    

    Would create a folder called src in your directory and add contents of your folder src into this.

    0 讨论(0)
  • 2021-01-31 02:35

    Suppose you want to copy the contents from a folder where you have docker file into your container. Use ADD:

    RUN mkdir /temp
    ADD folder /temp/Newfolder  
    

    it will add to your container with temp/newfolder

    folder is the folder/directory where you have the dockerfile, more concretely, where you put your content and want to copy that.

    Now can you check your copied/added folder by runining container and see the content using ls

    0 讨论(0)
  • 2021-01-31 02:38

    COPY . <destination>

    Which would be in your case:

    COPY . /

    0 讨论(0)
  • 2021-01-31 02:38

    Replace the * with a /

    So instead of

    COPY * <destination>

    use

    COPY / <destination>

    0 讨论(0)
提交回复
热议问题