Change the default data/image directory of docker

Post Reply
tthlan
Quản trị viên
Posts: 72
Joined: Tue Aug 23, 2016 8:13 am

Change the default data/image directory of docker

Post by tthlan »

Steps to change the default location.

Step 1. Stop docker daemon.
/etc/init.d/docker stop

Step 2. Make sure that there are no docker related processes.
ps aux|grep docker

Step 3. Move the contents of /var/lib/docker to your new location.
mv /var/lib/docker /home/

Step 4. Create a softlink to default location.
ln -s /home/docker/ /var/lib/docker

Step 5. Start docker daemon.
/etc/init.d/docker start

Step 6. Make sure all the images and data are working from the new location.

Copy from crybit

Notes:
- Step 3 is longest to processing. Unless dare remove with backup database and reinstall docker on computer, let the content of that folder is not heavy at all then able move it quickly. And then you should import an backup database on docker which is emty after you reinstall docker.

- Remove docker
sudo apt-get purge docker-engine
sudo apt-get autoremove --purge docker-engine

- Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Share your success !!!!
Post Reply