42Seoul/Docker

14. docker 메뉴얼 파해치기 Bind mounts

전에 설명햇듯 이건 공유해 주는 느낌이라고 생각하면 된다.

 

1. volume

-v 옵션과 --volume 으로 사용가능하다 이건 volume가서 보면 좀더 이해쉬움

2. mount

옵션이 추가됫다

bind-propagation = 바인드 전파를 정한다는데 옵션이 shared, slave, parivavte 등등 다양하다 뭔가 읽기 허용범위? 그리고 타입을 정하는? 거같다

 ==== -v ====
 docker run -d \
  -it \
  --name devtest \
  -v "$(pwd)"/target:/app \
  nginx:latest

==== --mount ====
docker run -d \
  -it \
  --name devtest \
  --mount type=bind,source="$(pwd)"/target,target=/app \
  nginx:latest

보다시피 $(pwd)같이 지금 경로를 지정할수 있다.

 

이것의 docker compose 를 보면

version: "3.9"
services:
  frontend:
    image: node:lts
    volumes:
      - type: bind
        source: ./static
        target: /opt/app/static
volumes:
  myapp:

이런식으로 되어있다

뭐 다들 아는부분이니깐 중요한거만

type =  타입 설정 

source = 공유할 폴더

target = 컨테이너안에 폴더위치

끝~

https://docs.docker.com/storage/bind-mounts/

 

Bind mounts

 

docs.docker.com