Docker Community Forums

Share and learn in the Docker community.

How to docker load from Windows shared file (.tar) in Ubuntu?


#1

I have 2 machines, one is a Windows 10, another is a Ubuntu Desktop (Ubuntu Cosmic 18.10).
Both are connected via LAN.
I’ve saved an image file (.tar) using docker save in Windows’s folder and already shared that file to everyone. I can access that file OK using UI in Ubuntu Desktop.

Now I would like to use docker load from Ubuntu machine (I’ve already installed docker engine in this machine). The issue is I don’t know how to pass the shared file path to the docker load.

After googling around, I’ve found that smbclient can be used to access remote (shared) file from Windows. After installing that tool in Ubuntu, I could really get a file with the following command:

smbclient '\\WindowsMachine\sharedFolder' -c 'get hello.txt'

It reports some message showing that it works (although I’m not sure where the hello.txt is saved or even if it’s saved or not).

That command is just for testing smbclient tool. What I need is something like passing the file content read by smbclient to the docker load (using one command line). Here is what I’ve tried:

sudo docker load < "$(smbclient '\\WindowsMachine\sharedFolder' -c 'get hello.tar')"

It reports “No such directory or file”. I’ve also tried this:

smbclient '\\WindowsMachine\sharedFolder' -c 'get hello.tar' | sudo docker load

It reports nothing, the root prompt is not shown and not any text is shown (I thought it was working hard). But if I press Enter, a new text line is printed saying

Error processing tar file(exit status 1): Unexpected EOF

Could you please help me sort out this issue? If one command-line solution is not feasible, I must of course go for multiple-command line solution (I’ve also not known of any).


(Tekki) #2

I would split this into 2 steps and first either copy the file from Windows or mount the share with mount -t cifs....
In your example I wonder why you don’t need a username/password to connect. And second, smbclient -c get copies the file to a local file and doesn’t send it to STDOUT.


#3

thank you for your reply. Actually my command will prompt for username/password after running (but I excluded that step from the question). For the smbclient -c looks like you’re right about its output saved to some file and not sent to STDOUT. Anyway the error message about No such file or directory is still confusing.

Actually I had to copy the shared file to Ubuntu using GUI tool ( =)). Solving this issue using command line is still preferred, especially when we can solve it using just one single command line (I’ve found some solution involving mounting shared folder as well).


(Tekki) #4

CIFS mounts are quite tricky, if you make a small mistake they don’t work and in most of the cases you don’t find out why. That’s why I prefer to mount the Windows share, so I (or my script) can check if the file is here before I do anything else.