docker kevin

Docker Storage: How to Change the Default Storage Driver and Volume Location

To set a new volume location for all of Docker, you need to change the default storage driver used by Docker. Here are the general steps to change the default storage driver and set a new volume location for Docker: 1.…

To set a new volume location for all of Docker, you need to change the default storage driver used by Docker.

Here are the general steps to change the default storage driver and set a new volume location for Docker:

  1. Stop the Docker daemon:

sudo systemctl stop docker

  1. Backup the current Docker configuration file:

sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.bak

  1. Create a new daemon.json file with the desired storage driver and volume location:

sudo nano /etc/docker/daemon.json

and add the following:

{    "data-root": "/new/volume/location",    "storage-driver": "overlay2"}

  1. Start the Docker daemon again:

sudo systemctl start docker

  1. Verify that the new storage driver and volume location are being used:

docker info

It's important to note that, changing the storage driver or the volume location could cause your existing containers and images to stop working properly, so make sure you have a backup of any important data before proceeding.

Also, you need to have root privileges to execute these commands.

It's always recommended to double-check the configuration settings and make sure they're correct, before making any changes to the settings.