-
docker 데이터 폴더 변경Docker 2019. 8. 12. 20:24
리눅스에서 docker 이미지는 기본적으로 /ver/lib/docker에 쌓인다.
내 컴퓨터의 경우 /에 할당된 디스크 용량은 50GB이고, 도커 데이터로 인해 공간이 부족해지면 문제를 발생시킨다.
그래서 /ver/lib/docker를 /home/bylee/data/docker로 변경한다.
다음은 docker info 명령어로 도커 데이터 위치를 확인한다.
[root@bylee5 docker.service.d]# docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 18.03.0-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c runc version: 4fc53a81fb7c994640722ac585fa9ca548971871 init version: 949e6fa Security Options: seccomp Profile: default Kernel Version: 4.17.3-100.fc27.x86_64 Operating System: Fedora 27 (Workstation Edition) OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 15.54GiB Name: bylee5 ID: 3AKC:QDXD:ML5K:IQLI:O74N:PXKK:A4PD:Q7X6:NYCP:E2NT:5DR2:6MNA Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Username: bitnine Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
변경하는 명령어는 다음과 같다.
# sudo mkdir /etc/systemd/system/docker.service.d # sudo touch /etc/systemd/system/docker.service.d/docker.conf # sudo vi /etc/systemd/system/docker.service.d/docker.conf [Service] ExecStart= ExecStart=/usr/bin/dockerd -g "/mnt/new_volume" # sudo systemctl daemon-reload # sudo systemctl start docker [root@bylee5 docker.service.d]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/docker.service.d └─docker.conf Active: active (running) since Wed 2018-10-10 15:05:29 KST; 2min 43s ago Docs: https://docs.docker.com Main PID: 453 (dockerd) Tasks: 24 Memory: 50.7M CPU: 1.361s CGroup: /system.slice/docker.service ├─453 /usr/bin/dockerd -g /home/bylee/data/docker └─461 docker-containerd --config /var/run/docker/containerd/containerd.toml
docker info 명령어로 다음과 같이 확인한다.
[root@bylee5 docker.service.d]# docker info Containers: 11 Running: 0 Paused: 0 Stopped: 11 Images: 97 Server Version: 18.03.0-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c runc version: 4fc53a81fb7c994640722ac585fa9ca548971871 init version: 949e6fa Security Options: seccomp Profile: default Kernel Version: 4.17.3-100.fc27.x86_64 Operating System: Fedora 27 (Workstation Edition) OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 15.54GiB Name: bylee5 ID: 3AKC:QDXD:ML5K:IQLI:O74N:PXKK:A4PD:Q7X6:NYCP:E2NT:5DR2:6MNA Docker Root Dir: /home/bylee/data/docker Debug Mode (client): false Debug Mode (server): false Username: bitnine Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
참고:
-https://sanenthusiast.com/change-default-image-container-location-docker/
-https://github.com/IronicBadger/til/blob/master/docker/change-docker-root.md'Docker' 카테고리의 다른 글
docker에서 ps 전체 삭제, image 전체 삭제, tag 삭제 방법 (0) 2019.08.12