This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
BKM: Change Docker Data Location
Xintian Wu edited this page Jul 25, 2022
·
11 revisions
The docker engine by default stores the data (images and containers) under the /var/lib/docker
directory. Usually this is a space-limited root partition. Use the following steps to change the docker data directory:
- Create new docker data directory under
/home
:
sudo mkdir /home/docker
sudo chown root.docker /home/docker
sudo chmod 700 /home/docker
- Modify
/etc/docker/daemon.json
to point to the new directory:
{
"graph": "/home/docker"
}
- Restart docker:
sudo systemctl stop docker
sudo systemctl start docker
- Remove the old data directory:
sudo rm -rf /var/lib/docker
If you haven't, create a containerd configuration file as follows:
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
Change the containerd data storage to /home/containerd
:
sed -i 's|^root =.*|root = "/home/containerd"|' /etc/containerd/config.toml
sudo mkdir -p /home/containerd
sudo systemctl stop containerd
sudo rm -rf /var/lib/containerd
sudo systemctl restart containerd
Add --root-dir=/home/kubelet
to the kubelet options in /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
, as follows:
[Service]
...
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS --root-dir=/home/kubelet
Then perform the following operations:
sudo mkdir /home/kubelet
sudo systemctl daemon-reload
sudo systemctl restart kubelet
- To test if Kubernetes properly recognizes your new data folder, try the following script:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
enableServiceLinks: false
containers:
- name: test
image: busybox
imagePullPolicy: IfNotPresent
command: ["sh","-c","while true; do df -h /mnt; sleep 1; done"]
volumeMounts:
- mountPath: /mnt
name: storage
volumes:
- name: storage
emptyDir: {}
- FFmpeg Framework
- GStreamer Framework
- NGINX Framework
- Scalable Video Technology
- Intel® OSPRay
- Open WebRTC Toolkit
- Useful FFmpeg Commands
- Useful GStreamer Commands
- Issues during Docker Build: Proxy, Time Zone and Error Code
- Reduce OpenVINO Size in Deployment
- Properly Reset Kubernetes
- Change Docker Data Location
- List and Delete iptables Rules
- How to build NEO for OpenCL on CentOS
- Setup Private Docker Registry with Self-Signed Certificates