클라우드 + DevOps/Docker

Docker 마운트 실습 :: 스토리지 드라이버 설정(--storage-opt)과 pquota 마운트

gamjadori 2024. 2. 29. 16:23
728x90

<스토리지 드라이버 설정(--storage-opt): pquota 마운트>

  • --storage-opt: 컨테이너를 실행할 때 스토리지 드라이버에 대한 추가적인 설정을 지정하는 데 사용
ubuntu@host1:~/Labs/ch06$ docker container run -it -v /home/ubuntu/Labs/ch06/nginx-log/:/webapp --name=mycontainer --storage-opt size=1g ubuntu:14.04 bash
docker: Error response from daemon: --storage-opt is supported only for overlay over xfs with 'pquota' mount option.
See 'docker run --help'.
>> 스토리지 드라이버가 xfs 파일 시스템 위에서만 'pquota' 마운트 옵션을 지원

 

<'pquota' 마운트 옵션 설정 방법>

ubuntu@host1:~/Labs/ch06$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=a77a1810-f798-4a6d-a1c3-3313bd3568d1 /               xfs     defaults        0       0
# /DATA was on /dev/sdb1 during installation
UUID=092849dd-123f-4110-b913-681edf89c4ab /DATA           ext4    defaults        0       2
# /var/lib/docker was on /dev/sdb2 during installation
UUID=d2d94fca-0deb-4b42-8015-62eaaa29e599 /var/lib/docker xfs     defaults        0       0
/swapfile                                 none            swap    sw

 

1. /etc/fstab 파일 편집

  • xfs 파일 시스템에 'pquota' 마운트 옵션을 추가
ubuntu@host1:~/Labs/ch06$ vi /etc/fstab

2. /etc/default/grub 파일 편집

  • GRUB_CMDLINE_LINUX_DEFAULT="quiet splash roorflags=uquota,pquota:q” 수정
ubuntu@host1:~/Labs/ch06$ vi /etc/default/grub

>> 루트 파일 시스템의 마운트 옵션을 설정

  • uquota: 사용자 디스크 사용량(Quota)를 활성화
  • pquota:q: 프로젝트 디스크 사용량(Quota)와 디스크 사용량 제한(Quota)을 활성화

 

<파일 편집 후 컨테이너 생성>

ubuntu@host1:~/Labs/ch06$ docker run -it -v /home/kevin/myvolume:/webapp --name=mycontainer --storage-opt size=1G ubuntu:14.04 bash
/home/kevin/myvolume" 디렉터리가 컨테이너 내의 "/webapp" 경로에 마운트되며,
컨테이너는 1GB의 스토리지를 할당받아 실행