Skip to main content
Skip table of contents

Change Docker default directory

The following config will guide you through a process of changing the docker's default /var/lib/docker storage disk space to another directory.

  1. Login to CentOS and edit or create /etc/docker/daemon.json
  2. Add the following piece of code to the file you have just opened:
    1. CODE
      {
      "data-root": "/home/var"  
      }
      
      
  3. Stop the docker service using 
    1. BASH
      systemctl stop docker
  4. Wait for sometime for all the docker containers to shutdown gracefully
  5. Reload the systemd configuration for  new changes to be effective.
    1. BASH
      systemctl daemon-reload
      
      
  6. Create the new directory to be the new home for docker service. For example, if you want /home/var to be the home for Docker service, create the directory by using following command.
  1. BASH
    mkdir /home/var
  • Copy or sync all the current containers to the new root directory for docker.
    1. BASH
      rsync -aqxP /var/lib/docker/ /home/var
  • Start the docker service daemon 
  1. BASH
    systemctl start docker
  • That's it. If you have done everything correctly, Docker service should be started normally. Verify all the containers are up and running successfully by running following command.
    1. BASH
      docker ps -a



JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.