How to move the Docker and Containerd Root Directory
Overview
During the installation of a vFunction Server on a Linux VM, the script checks to make sure there is at least 5gb of free space in the default Docker root directory, /var/lib/docker/ for the vFunction Container images.
With newer versions of Dockers, the Container Image management is done by Containerd. Containerd writes these files to /var/lib/containerd.
Modify the default location of the Docker and Containerd Root Directories to move all functionality from /var/lib to another location on the filesystem.
Steps to change the Docker Root Directory
Take the following steps to move the default Docker root directory if the disk space on the VM exists in another location.
In this example /app/docker is used as the new default Docker root directory. Replace this directory with your actual location in the steps below.
- Stop the Docker.service, Docker.socket and Containerd.service
sudo systemctl stop docker.service docker.socket containerd.service
- If required, create the directory structure for Docker
mkdir -p /app/docker/
- Move the default Docker Root Directory to the new location
sudo mv /var/lib/docker/* /app/docker/
- Modify the Docker Daemon JSON
sudo vi /etc/docker/daemon.json
### Add these lines to this file (or point to the alternate, new path used)
{
"data-root": "/app/docker"
}
- Start the Docker and Containerd services
sudo systemctl start containerd.service docker.service
- Confirm that the new Docker Root Directory was applied
docker info -f '{{ .DockerRootDir}}'
- Install (a new server) or Restart (an existing) vFunction Server
sudo bash /opt/vfunction/server-installation/install.sh
sudo bash /opt/vfunction/server-installation/restart-server.sh
Steps to change the Containerd Root Directory
Take the following steps to move the default Containerd root directory if the disk space on the VM exists in another location.
In this example /app/containerd is used as the new default Containerd root directory. Replace this directory with your actual location in the steps below.
- Stop the Docker.service, Docker.socket and Containerd.service
sudo systemctl stop docker.service docker.socket containerd.service
- If required, create the directory structure for Containerd
mkdir -p /app/containerd
- Move the default Containerd Root Directory to the new location
sudo mv /var/lib/containerd/* /app/containerd/
- Modify the Containerd config.toml’s root location
sudo vi /etc/containerd/config.toml
### Modify the Root location to point to, in this example, /app/containerd
root = "/app/containerd"
...
- Start the Docker and Containerd services
sudo systemctl start containerd.service docker.service
- Install (a new server) or Restart (an existing) vFunction Server
sudo bash /opt/vfunction/server-installation/install.sh
sudo bash /opt/vfunction/server-installation/restart-server.sh