安装docker后修改docker文件目录

docker会下载容器,运行会挂载磁盘,所以我们需要把docker装在大容量的分区。

安装

https://docs.docker.com/install/linux/docker-ce/centos/

修改位置

查看我们挂载的磁盘

# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  1.7M  1.6G   1% /run
/dev/sda2       110G   18G   86G  18% /
tmpfs           7.8G  152M  7.7G   2% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sdb1       916G   77M  870G   1% /data
/dev/sda1       511M  6.1M  505M   2% /boot/efi
tmpfs           1.6G   16K  1.6G   1% /run/user/121
tmpfs           1.6G   28K  1.6G   1% /run/user/1000
tmpfs           1.6G     0  1.6G   0% /run/user/0

选择 /data作为docker容器存放地址。


docker info  #查看docker的基本信息
#停止docker服务
systemctl stop docker

#备份原目录
cp -r /var/lib/docker  /data/docker
mv /var/lib/docker /var/lib/docker.bak
ln -s /data/docker /var/lib/docker
systemctl start docker


运行Hello world



# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
 

查看docker info



# docker info
Containers: 3
 Running: 0
 Paused: 0
 Stopped: 3
Images: 1
Server Version: 18.09.7
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.18.0-20-generic
Operating System: Ubuntu 18.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.54GiB
Name: ryan-computer
ID: P5ON:MZEK:XB4K:63NP:DTUX:BQHY:72AR:OP4G:JQ2M:JNDL:T6TU:6NEJ
Docker Root Dir: /data/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support

posted @ 2019-07-04 15:01  Ryan.Miao  阅读(10207)  评论(0编辑  收藏  举报