Giter VIP home page Giter VIP logo

Comments (10)

pmorie avatar pmorie commented on July 20, 2024

+1 to addressing this, it feels like a bug in the implementation of the Dockerfile format.

from imagebuilder.

QiWang19 avatar QiWang19 commented on July 20, 2024
// from source wildcards is only a file
// result: a file
$ ./imagebuilder -f Dockerfile.wildcard .
--> FROM alpine as 0
--> COPY ./README.m* /cp
--> RUN ls -l cp
-rw-rw-r--    1 root     root          3922 Aug  9 16:41 cp
--> Committing changes ...
--> Done


//from source wildcards is a folder
// result: directory
$ ./imagebuilder -f Dockerfile.wildcard .
--> FROM alpine as 0
--> COPY ./READMED* /cp
--> RUN ls -l cp
total 4
-rw-rw-r--    1 root     root            13 Aug  9 17:01 cpreadme
--> Committing changes ...
--> Done

// from the source, wildcards could be a folder and a file
// result: directory includes the folder and the file
$ ./imagebuilder -f Dockerfile.wildcard .
--> FROM alpine as 0
--> COPY ./README* /cp
--> RUN ls -l cp
total 8
-rw-rw-r--    1 root     root          3922 Aug  9 16:41 README.md
drwxrwxr-x    2 root     root          4096 Aug  9 17:01 READMEDIR
--> RUN ls -l cp/READMEDIR
total 4
-rw-rw-r--    1 root     root            13 Aug  9 17:01 cpreadme
--> Committing changes ...
--> Done

imagebuildah can determine whether the target should be a single file or a directory if the wildcard is only a file or a folder.
I think the issue is, when wildcards could be a folder and a file, we get result: new directory including the folder and the file. Expect result shoud be :
if target path is not a directory, should report error message, the destinations must ends with a '/'
if target path is a directory, should copy the file under the source folder and the source file

from imagebuilder.

QiWang19 avatar QiWang19 commented on July 20, 2024

@rhatdan @TomSweeneyRedHat I played with imagebuilder I think the issue does not exist. But found difference between imagebuilder with docker.
Can this issue be closed?
Should I work on a PR to fix the difference between imagebuilder and docker?

from imagebuilder.

rhatdan avatar rhatdan commented on July 20, 2024

What is the difference between imagebuilder and Docker.

from imagebuilder.

QiWang19 avatar QiWang19 commented on July 20, 2024

What is the difference between imagebuilder and Docker.

from the source, wildcards could be a folder and a file
imagebuilder result: directory includes the folder and the file
docker result: directory includes the content of the folder and the file

imagebuilder allows COPY ./README* /cp,
docker will return error When using COPY with more than one source file, the destination must be a directory and end with a /, should use COPY ./README* /cp/

$ ./imagebuilder -f Dockerfile.wildcard .
--> FROM alpine as 0
--> COPY ./README* /cp
--> RUN ls -l cp
total 8
-rw-rw-r--    1 root     root          3922 Aug  9 16:41 README.md
drwxrwxr-x    2 root     root          4096 Aug  9 17:01 READMEDIR
$ sudo docker build -t wildimg1 -f Dockerfile.wildcard .
Sending build context to Docker daemon  34.28MB
Step 1/3 : FROM alpine
Step 2/3 : COPY ./README* /cp/
Step 3/3 : RUN ls -l cp
total 8
-rw-rw-r--    1 root     root          3922 Aug  9 16:41 README.md
-rw-rw-r--    1 root     root            13 Aug  9 17:01 cpreadme  //cpreadme is in the folder READMEDIR

from imagebuilder.

rhatdan avatar rhatdan commented on July 20, 2024

So docker automatically appended the "/" on the end of /cp?

from imagebuilder.

TomSweeneyRedHat avatar TomSweeneyRedHat commented on July 20, 2024

and make sure you're using Docker latest 1.19.+, not Docker 1.13.1

from imagebuilder.

QiWang19 avatar QiWang19 commented on July 20, 2024

So docker automatically appended the "/" on the end of /cp?

No. without / in the end, docker stoped after return the message

Step 2/4 : COPY ./README* /tmp/cp
When using COPY with more than one source file, the destination must be a directory and end with a /
[qiwan@qiwan imagebuilder]$ 
sudo docker -v
Docker version 19.03.1, build 74b1e89

from imagebuilder.

rhatdan avatar rhatdan commented on July 20, 2024

We should do the same. We of course could check if /tmp/cp exists and is a directory then allow the COPY

from imagebuilder.

QiWang19 avatar QiWang19 commented on July 20, 2024

I think this can be closed. I didn't find the bug as described in this issue (doesn't seem to look at the result of a source wildcard expansion to determine whether the target should be a single file or a directory).

The differences with docker I found #135 (comment) was one of the problems in issue #139. PR #138 is fixing...

from imagebuilder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.