I can't copy directory with Docker

Hello everybody,

I’m using this line to download a file in my dockerfile :

ADD https://tomjedusor:666@192.168.100.17/factory/myfolder/myfile /tools

it works fine.
Though, when I do the following I get a 401 “Authentication is required”:

ADD https://tomjedusor:666@192.168.100.17/factory/myfolder /tools

What am I doing wrong please ?
I’m using Docker 20.10.24, my host is a debian 12 as well as my container.
I tried to use COPY, but it doesn’t not work with URLs. I just want to download the content of the remote directory inside my container.

Thank you all in advance !

You can not add a folder via http. Http only has single files specified, no directory listing, so it can not iterate over potential files on the server.

Thank you for your answer, so, dealing with http, there’s no way to download the content of a folder, not knowing what’s inside of it ?

When you do get a list of files in browser, it is a custom HTML page from the server.

There is no standard for file lists in http, so you can’t download all files of a folder at once.

Workaround could be to create a ZIP on the server, download and unpack it.

Maybe check if WebDAV is supported as protocol.

The point is, I have to split my file cause there is a file size limitation…

Please take a look at the documentation:
https://docs.docker.com/reference/dockerfile/#add

If the src for an ADD instruction is an URL, only a single get request will be made. Either you are going to follow the suggestion of @bluepuma77 and make the url return a single tar file archive using a supported compression format (identity , gzip , bzip2 or xz), or you will have to add as many ADD instructions as files that you want to download.

Though, what you need could be a wget command in a RUN instruction that recursively downloads or mirrors a subpath of a URL. A short google search should yield plenty of blog post for this subject.