Linux

Docker Data Folder Configuration

uthline 2020. 1. 17. 07:26
반응형

How To Change Docker Data Folder Configuration

https://medium.com/@ibrahimgunduz34/how-to-change-docker-data-folder-configuration-33d372669056
docker의 data가 /에 쌓이게되면 용량문제가 있다.
용량이 풍부한 HDD(/home/)으로 경로를 변경하는 방법이다.

아래 파일 수정.
/usr/lib/systemd/system/docker.service

AS-IS

[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

TO-BE

[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 $DOCKER_OPTS
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

데몬.config 수정

$ cat /etc/docker/daemon.json
{
  "data-root": "/home/uthline/docker"
}

mkdir

/home/uthline/docker

docker restart

sudo systemctl restart docker

Etc.

최근 docker 13.1에서는 위와 같은 방법으로 data-root가 변경되지 않은 것을 확인하였다. 그럴땐 아래와 같은 방법으로 시도해보시길...

sudo vi /etc/sysconfig/docker

AS-IS

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.

TO-BE

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --graph=/home/irteamsu/docker'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.
반응형