简体   繁体   中英

How can a docker container get full access to a windows share without mounting the share in the host OS?

I'm using docker on linux and I want to allow my containers to have full access to a windows share (named myshare with appropriate permissions set) that has the following structure:

d:\myshare
       foo
       bar

As a test, I've verified that putting the following in /etc/fstab will create a mount that allows me to RW to the windows share.

//172.16.68.6/myshare  /home/me/foo  cifs username=myuser,password=mypass,domain=172.16.68.6,uid=1000

Instead of using /etc/fstab I'd like to be able to create a volume in docker so that I can do something like the following in my docker-compose.yml

volumes:
  - /myshare/foo:/foo

Ideally, I'd like to be able to create one volume then just append the directory name (like I did above with foo ) so I don't have to create multiple volumes. But so far I can't even create a mount on the docker host that connects to the windows share. I wouldn't even know how to "peek" inside of the volume. I've tried using portainer, but it tells me the volume isn't being used.

How can I create this volume and consume it (preferably in docker-compose)?

I think the answer is to use a docker volume plugin. https://docs.docker.com/engine/extend/plugins_volume/

Preferably, one already exists. Google it, find it, and follow its instructions. You should be able to do it. Check out https://docs.docker.com/engine/extend/legacy_plugins/ for possible candidates.

Alternatively you can write your own docker volume plugin. Be sure to publish it for the benefit ot others. This will require a considerable amount of skill, so it might not be practical.

Here is my docker-compose.yml that is working for me. You must use the ip address in the path:

version: '3.3'
services:
  my-service:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - logs:/mnt/logs

volumes:
  spark_logs:
    driver: local
    driver_opts:
      type: cifs
      device: "//10.1.1.7/path/prd/sist/log"
      o: username=${USER},password=${PASS},file_mode=0444,dir_mode=0444

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM