f3 icon indicating copy to clipboard operation
f3 copied to clipboard

Help with Docker

Open archiif opened this issue 3 years ago • 3 comments

Anyone know how to work with the Docker commands on Windows? docker run -it --rm --privileged -v <device>:<device> f3:latest <f3-command> [<f3-options>] <device> I'm not sure how to substitute <device>. If anyone have some examples, that would be great.

archiif avatar Jul 19 '20 23:07 archiif

I just got it working on my Mac, though not without some difficulty. @peron @AltraMayor I think the docker instructions are a bit minimalistic and invite lots of questions like these. Let me know if you'd like me to write up + PR this slightly more detailed guide in the README.

Short Answer

The short answer is that <device> should be the path of where the drive is mounted, for example D:/myflashdrive or in my case, /Volumes/myflashdrive/. Also note that I think f3:latest should be peron/f3 or peron/f3:latest. Probably for @peron he didn't need to type that because it was his own account.

<f3-command> is something like f3probe, and <f3-options> are the command line options. For example:

docker run -it --rm --privileged -v D://flashdrive:/dev/usb peron/f3 f3probe --destructive --time-ops /dev/usb

Docker and USB Devices

But there's a catch... which is that on non-linux OS's (well at least for my Mac), it seems Docker isn't really able to handle "forwarding" usb devices even with the "privileged" flag (docker issue). I kept getting errors like f3probe: Can't open device '/opt/usb': Is a directory. Even though I could properly ls /opt/usb to see the files, f3 wasn't liking it.

So I followed this guide to allow the usb device to forward: Using USB with Docker for Mac. It's geared towards a serial port type device, but still applies if you just use the appropriate vendor and product id's. Here's what I typed into my Mac terminal (probably similar for windows powershell or wherever you execute docker commands) (abridged from the above link):

docker-machine create -d virtualbox default
docker-machine stop
vboxmanage modifyvm default --usb on
docker-machine start
vboxmanage usbfilter add 0 --target default --name flashdrive --vendorid 0x0123 --productid 0x4567
eval $(docker-machine env default)

For the usbfilter add command, note that the "name" argument is the new name you're giving the filter so you can name it whatever you want. --vendorid and --productid are optional arguments according to the documentation so I'm not sure what would happen if you left those out - I assume it would capture all your USB devices. To be safe, you can find the vendorid and productid without too much difficulty. For example, in Mac open up "System Information", scroll down to "USB" and it has the info there. You can also try vboxmanage list usbhost according to the blog post, though I didn't try it.

Once you've run the above commands, unplug and replug the flash drive and run docker-machine ssh default "lsblk" to list the devices. Search for the correct drive - the "SIZE" column may be helpful. In my case, it was "sdb". Now run

docker run --rm -it --device /dev/sdb peron/f3 f3probe --destructive --time-ops /dev/sdb

Note the use of the --device argument rather than privileged - I assume both would work but I figure device is more appropriate here. Alternatively, I find it helpful to enter into a bash prompt so that I can poke around the docker vm: docker run --rm -it --device /dev/sdb peron/f3 bash so that you can run commands like ls /dev/* and stuff.

gchenfc avatar Jul 29 '20 22:07 gchenfc

A pull request to improve the information about Docker in the README, or another documentation file, is welcome.

Thank you for your contribution, @gchenfc.

AltraMayor avatar Jul 30 '20 11:07 AltraMayor

Thank you for the detailed write-up gcjemfc! Unfortunately I settled on installing it on WSL, so I won't be able to test this for a while.

archiif avatar Jul 31 '20 09:07 archiif