Laboratorium Komputerowe Progmar

We are using cookies in the page. If you use the page you agree for the cookies.      Close

Moving Docker's storage directory to different location

  1. Edit file /lib/systemd/system/docker.service and replace line: ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS with following line: ExecStart=/usr/bin/dockerd -g /new/path/docker -H fd:// $DOCKER_OPTS where /new/path/docker specifies destination directory that shold store Docker's images.
  2. Stop Docker service: sudo systemctl stop docker
  3. Make sure that Docker service stopped properly: sudo ps aux | grep -i docker | grep -v grep If the command above does not output anything that it is all OK.
  4. Because Docker systemd unit configuration file has changed you have to reload systemd configuration. You can do it with following command: systemctl daemon-reload
  5. Move all content of /var/lib/docker directory to the new desired location: sudo rsync -aqxP /var/lib/docker/ /new/path/docker If you want to have access to the new Docker's storage area then you should change its owner nad group: sudo chmod -R username:groupname /new/path/docker
  6. Start Docker service: sudo systemctl start docker
  7. Make sure that the service runs properly: ps aux | grep -i docker | grep -v grep If the command above will give some output then everything is OK.