Wednesday, October 10, 2018

How to change data directory for Docker with systemd

How to change the data directory for Docker with systemd ?



Recently I was playing with docker and got the issue with system space utilization which got full when I tried to pull some new images form docker hub. The reason was that partition was full where docker was storing all data including images.

     Usually, By default docker store its all data in /var/ partition which is usually will be in root"/" partition or have can have the separate partition. In my case that was in root "/" partition. So I thought of moving this data directory to somewhere else. Moving this directly to non OS or non-default partition will be a good habit as it will not harm data if something goes wrong with the system.

You have different option to do this -

1. Use "--graph=/data/docker/data" in systemd file i.e. "/usr/lib/systemd/system/docker.service" as below -

               ExecStart=/usr/bin/dockerd --graph="/data/docker/data"

2. Create daemon.json file with below content-

# cat /etc/docker/daemon.json
   {
    ..
    "graph": "/data/docker/data"
    ..
   }

Other Useful hacks -

Full Information about docker service -
# systemctl show docker 
Type=notify
Restart=on-failure
NotifyAccess=main
RestartUSec=100ms
TimeoutStartUSec=infinity
TimeoutStopUSec=1min 30s
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestamp=Wed 2018-10-10 18:06:50 IST
WatchdogTimestampMonotonic=6232790274
FailureAction=none
PermissionsStartOnly=no
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=6076
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success
ExecMainStartTimestamp=Wed 2018-10-10 18:06:48 IST
ExecMainStartTimestampMonotonic=6231265813
ExecMainExitTimestampMonotonic=0
.
.
.

More detailed info on official site .

Happy Learning !!


Kubernetes 1.31 || Testing the Image Volume mount feature using Minikube

With Kubernetes new version 1.31 ( https://kubernetes.io/blog/2024/08/13/kubernetes-v1-31-release/ ) there are so many features releases for...