Skip to content

Instantly share code, notes, and snippets.

@realFranco
Last active August 30, 2022 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realFranco/36d2245295fabc9a56c5f8c870d8cef0 to your computer and use it in GitHub Desktop.
Save realFranco/36d2245295fabc9a56c5f8c870d8cef0 to your computer and use it in GitHub Desktop.
Change the "data-root" from the "docker" service, with the goal to reduce utilization on the "/var" partition.
# Motivation: As the "/var" partition (Linux Debian) could have a limited size
# and "docker" by default set volumes and images inside of "/var/lib" the partition
# could run out ouf space soon.
#
# My approach is to modify the "data-root" argument from the docker daemon, and move
# all the data into a partition with more free space ("home" in my case).
> docker version
Client:
Version: 20.10.12
API version: 1.41
Go version: go1.16.2
Git commit: 20.10.12-0ubuntu2~20.04.1
Built: Wed Apr 6 02:14:38 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
# Steps:
> sudo su
> service docker status | stop
# If the docker is still runing becaouse of the docker.socket.
> systemctl stop docker.socket
# On my case "/home/diuble-lig/docker/" is my folder destination.
> rsync -a /var/lib/docker/* /home/diuble-lig/docker/
# Wait some minutes until the folder finish the creation
> nano /lib/systemd/system/docker.service
# Add --data-root parameter
ExecStart=/usr/bin/dockerd --data-root /home/diuble-lig/docker -H fd://
> systemctl daemon-reload
> service docker restart
> service docker status
# Pull a docker hello world image or some another images, for my test case "busybox".
> docker run -it --rm busybox
# Ref: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon
# Ref: https://stackoverflow.com/questions/32070113/how-do-i-change-the-default-docker-container-location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment