give docker read write access to external hard drive

Post Reply
c0rs4ir
New here
Posts: 8
Joined: Sat Apr 29, 2017 9:47 am

give docker read write access to external hard drive

Post by c0rs4ir » Sun Jan 07, 2018 2:00 pm

I have a USB 3.1 connected to the NAS. Is there a method my docker SANnzbd can have read,write access to the external hard drive. Any known way of adding a shared folder to it?

paponius
Starting out
Posts: 11
Joined: Sat Jun 09, 2018 11:03 pm

Re: give docker read write access to external hard drive

Post by paponius » Thu Oct 08, 2020 10:08 pm

Could be done by a command.
Seems to me, this is not possible to do using QNAP interface.
But this is not a limitation of docker itself.

1. It would be expected to have an option to add external volumes
2. It still should be possible to add external volume in
Create Container dialog > Shared Folders > Volume from host

I think this deserves a consideration from QNAP. Fill a support ticket.

What I did on TS-x53A to have access to external drive in docker image:

open shell on host (standard SSH on your NAS)

$ mount
# check path of your external drive
$ docker run -it -v /share/external/DEV3301_1:/mnt/ext_drive --name my_name ubuntu:18.04 /bin/bash
/share/external/DEV3301_1 - where I found my external HDD to be mounted on the Host
/mnt/ext_drive - any path in docker will do
my_name - any or none (which results in funny names) how the container will be named
ubuntu:18.04 - this image is now available in QNAP store and I already had it in "Images". If you use just 'ubuntu' it will download ubuntu:latest as a separate new image and create a container from that.

after this command you'll be in console of the created docker image in your terminal. To return to host console type 'exit'
to get back into docker console again,
1. start the container using QNAP UI Container station, or "$ docker start my_name"
2. use a console in QNAP docker UI, or: $ docker exec -it my_name bash (add "--user root" for root access)

Note: As this is not a standard way of adding containers to Container station, there might be some differences with containers from those created from QNAP UI.
e.g. I noticed default user is root. These differences could be fixed if necessary. maybe by wrapping 'docker' script and logging arguments used by QNAP when container is created.

btw. I've been doing this to shred a disk. as shred command is not available on the Host and I did want to see the result after hours of shredding, doing it from a docker image seemed like the easiest way.
In the docker image, I did 'cd' into the root of the drive, in QNAP UI Container Station terminal, then: $ find . -type f -exec shred -v -n 1 -u {} \; and went to sleep
Sure, this is just an easy lazy wipe, but that's what i needed, no discussions there.

Post Reply

Return to “Container Station”