By Default Docker deploying the containers in /var/lib/docker. If Required to deploy the containers in custom path we can follow the below steps.
Note: Please take the necessary snapshot before performing the activity.
Step 1: Stop the Docker services.
systemctl stop docker
Step 2: Create the Directory with proper permissions Where it's required.
mkdir -p /docker_data
chown root:root /docker_data
chmod 711 /docker_dataStep 3: If it's existing environment follow the below steps if it's new environment and not deployed any containers yet, you can skip to step 4
rsync -aP /var/lib/docker/ /docker_data/Step 4: Create or add the content in json file (vi /etc/docker/daemon.json).
{
"data-root": "/docker_data"
}Step5: Restart the docker services.
systemctl start dockerto verify the custom path of containers
docker info | grep 'Docker Root Dir'Output:
Docker Root Dir: /docker_dataif Required you can remove the old data located in /var/lib/docker to utilize the space.
Comments
0 comments
Please sign in to leave a comment.