Modify the Docker image and the container storage location.

Source: Internet
Author: User
Tags mkdir


By default, Docker is stored in the following locations:

/var/lib/docker

Generally under the root partition we will not give too much. The more images and containers we have, the more generally we have two workarounds.

1. Mount large partitions to/var/lib/docker:

Generally choose to establish logical partition LVM to facilitate later expansion of the collective.

A. Create a new partition and format it

PS: The following operation construction you already have ready-made volume groups, directly can be zoned logical volumes. Or you can create a logical volume yourself, or use a partition that does not apply to logical volumes

Lvcreate-l 300G lv_docker vg_home
mkfs.ext4/dev/vg_home/lv__docker

B. Mounting a new partition to a temporary mount point

Mkdir/mnt/docker
mount/dev/vg_home/lv_docker/mnt/docker/

C. After you stop the Docker, copy the/var/lib/docker data to the temporary mount point

Service Docker stop
cp-r/var/lib/docker/*/mtn/docker

D. Modify/var/lib/docker to//var/lib/docker.bak and create/var/lib/docker

Mv/var/lib/docker{,.bak}
Mkdir/var/lib/docker

E. Mount the new partition to the/var/lib/docker, and set the boot auto mount.

Mount/dev/vg_home/lv_docker/var/lib/docker
vim/etc/fstab
---
/dev/vg_home/lv_docker/docker_data	ext4	defaults 0 0
---- 

F. Detect if Docker is available and data is complete

Docker images

G. Uninstall the temporary mount point after confirming the error, remove the/var/lib/docker.bak

Umount/mnt/docker
Rm-rf/var/lib/docker.bak



2, modify the image and container storage path:

It is simple to specify that the parameters for mirroring and container storage paths are--graph=/var/lib/docker.


We just need to modify the configuration file to specify the startup parameters.

Vim/etc/sysconfig/docker
------------
other_args= "--graph=/docker"
------------

Stop Docker.

Service Docker stop

Back up data to a new container storage directory

Cp-r/var/lib/docker/docker/

Modify Source Store Directory name

Mv/etc/lib/docker{,.bak}

Start Docker

Service Docker start

Test

Docker images



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.