Docker 기본 컨테이너 저장 경로 변경

 

Docker 기본 컨테이너 저장 경로 변경

기본적으로 docker는 / (root 파티션) 아래에 기본 저장 경로를 가지고 있습니다.

만약 데이터를 쌓는 컨테이너를 포함하게 되면, 무한정 늘어나는 컨테이너 때문에 파티션 Full 발생에 의한 장해를 겪을 수 있습니다.

현재 버전(Docker-ce 18버전 이상)을 설치하면 /lib/systemd/system/docker.service 부분이 생깁니다.

해당 부분을 vi 로 편집해 줍니다.

# vi /lib/systemd/system/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
...
...
...
...

이렇게 안쪽 내용이 보입니다.

변경 부분은 ExecStart 부분입니다. -g 옵션을 주고, docker 컨테이너가 저장될 경로를 지정해 주면 됩니다.

FROM:
ExecStart=/usr/bin/dockerd daemon -H fd://

TO:
ExecStart=/usr/bin/dockerd daemon -g /new/path/docker -H fd://

그리고 나서 systemctl restart docker 해주면 됩니다.

소셜 미디어로 공유하기

You may also like...

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

 

새 블로그로 이사갑니다.

 

rastalion.dev

 

도메인 변경했어요. 현재 지속적으로 개선 중입니다.

 

This will close in 10 seconds