Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change docker installation directory in centos 7 with docker 1.13 version

Tags:

docker

centos7

I have enclosed the docker details below,

$ docker info

Containers: 3
 Running: 3
 Paused: 0
 Stopped: 0
Images: 26
Server Version: 1.13.0
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.6.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.51 GiB
Name: docker
ID: WYAF:SDYL:LVAU:OKDP:O6K2:ZLG6:RMIB:SET4:SWGN:6TBR:ST6K:4W55
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

$ docker system df

TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              4                   3                   4.441 GB            -1.644e+09 B (-37%)
Containers          3                   3                   6.867 GB            0 B (0%)
Local Volumes       0                   0                   0 B                 0 B

$ df -h

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   14G   14G  647M  96% /
devtmpfs                 7.8G     0  7.8G   0% /dev
tmpfs                    7.8G     0  7.8G   0% /dev/shm
tmpfs                    7.8G   25M  7.8G   1% /run
tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda1                497M  216M  281M  44% /boot
/dev/sdb                 296G   65M  281G   1% /mnt
overlay                   14G   14G  647M  96% /var/lib/docker/overlay/dfa0c4e618c259bf046b454b27a7963fb31b9d4e95cc745ed28696b0791e3166/merged
shm                       64M     0   64M   0% /var/lib/docker/containers/6e978cecc472322ef984cdb73117ed0243eb88c30d37c93827084bec88dcf15a/shm
overlay                   14G   14G  647M  96% /var/lib/docker/overlay/9cdd3dc933f93febccaa7e06ba2f86023d3dd655614be5d9e636ab75f21873f4/merged
shm                       64M     0   64M   0% /var/lib/docker/containers/ed44174945e331246f622e42a6ea646504075a91e4922168d895ed295cd24109/shm
overlay                   14G   14G  647M  96% /var/lib/docker/overlay/c2bc2c73f0f3b0e717f8ea134aad8554ebb6b77c2dcfd85e8035a645bf75d074/merged
shm                       64M     0   64M   0% /var/lib/docker/containers/26fd8e67dc7da80f6047add17aaddd7f67f763966d4a6b65d08680ac41774a28/shm
tmpfs                    1.6G     0  1.6G   0% /run/user/0

As we can see the space in root directory is filled up, so i would like to mount the docker installation directory to /mnt. Many suggested to include the -g option, but i couldnt able to provide that option.

Could anyone please help me how to mount to /mnt directory and where to make those changes. I am using centos 7 and i have installed docker with the help of below link and i have followed exactly the same steps,

https://docs.docker.com/engine/installation/linux/centos/

And followed the steps provided here https://forums.docker.com/t/how-do-i-change-the-docker-image-installation-directory/1169

I couldnt find a docker file in /etc/sysconfig or in /etc/default. Please suggest where to change this

like image 597
Jugi Avatar asked Feb 16 '17 16:02

Jugi


1 Answers

According to the Docker Document, the recommended way is to use the platform-independent daemon.json file, which is located in /etc/docker/ on Linux by default.

Set the following flags in the daemon.json file:

{
  "data-root": "/mnt/docker-data",
  "storage-driver": "overlay"
}
like image 71
David Ding Avatar answered Sep 28 '22 03:09

David Ding