[Docker Compose] Volume Mount 상대경로

aqualung·2024년 7월 25일
volumes:
  certbot_conf_volume:
    name: certbot_conf_volume
    driver_opts:
      type: none
      device: ./data/certbot/conf # 상대경로 X
      o: bind

특정 경로에 볼륨을 마운트하려 할 때 상대경로를 사용할 수 없다.

이럴때는 환경변수 PWD를 이용해 절대경로로 바꿔주어야 한다.

volumes:
  certbot_conf_volume:
    name: certbot_conf_volume
    driver_opts:
      type: none
      device: ${PWD}/data/certbot/conf # 상대경로 X
      o: bind

PWD는 운영체제마다 다를 수 있으니 명령어로 확인해보고 작성하도록 하자.

0개의 댓글