카테고리 없음

네트워크 드라이브를 도커에 마운트하기

백봉 2024. 4. 26. 11:57

도커 컴포즈

 

version: '3'

services:
  box1:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "9219:9219"
    volumes:
      - type: volume
        source: nfs-volume
        target: /app/firmware

volumes:
  nfs-volume:
    driver_opts:
      type: "nfs"
      o: "addr=192.168.0.10,nolock,soft,rw"
      device: ":/nfsshare/nfsshare/firmware"

 

주의할 것은

device 에서 공유명/첫번째 폴더/그밑의 폴더

 

참고: https://blog.markfrancis.io/post/2020-07-16-mounting-network-shares-in-docker-compose/

 

Host requirements

  • The packages needed for NFS shares. On Ubuntu this is nfs-common. OR
  • The packages you need for SAMBA/CIFS shares. On Ubuntu this is cifs-utils.

Docker-compose.yml example for NFS

version: "3.7"

services:
  home-assistant:
  container_name: home-assistant
    image: homeassistant/home-assistant
    ports:
      - "8123:8123"
    volumes:
      - type: volume
        source: home-assistant-data
        target: /config
        volume:
          nocopy: true
    restart: always

volumes:
  home-assistant-data:
    driver_opts:
      type: "nfs"
      o: "addr=192.168.1.10,nolock,soft,rw"
      device: ":/tank/home-assistant-data"

Docker-compose.yml example for SAMBA/CIFS

version: "3.7"

services:
  home-assistant:
  container_name: home-assistant
    image: homeassistant/home-assistant
    ports:
      - "8123:8123"
    volumes:
      - type: volume
        source: home-assistant-data
        target: /config
        volume:
          nocopy: true
    restart: always

volumes:
  home-assistant-data:
    driver_opts:
      type: "cifs"
      device: "//192.168.1.10/home-assistant-data"
      o: "addr=192.168.1.10,rw"
      o: "uid=0,username=samba-username,password=samba-password,file_mode=0770,dir_mode=0770"