首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >安装docker后修改docker文件目录

安装docker后修改docker文件目录

作者头像
Ryan-Miao
发布2019-07-08 17:27:41
发布2019-07-08 17:27:41
1.9K00
代码可运行
举报
文章被收录于专栏:Ryan MiaoRyan Miao
运行总次数:0
代码可运行

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

安装

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

修改位置

查看我们挂载的磁盘

代码语言:javascript
代码运行次数:0
运行
复制
# 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容器存放地址。

代码语言:javascript
代码运行次数:0
运行
复制
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

代码语言:javascript
代码运行次数:0
运行
复制
# 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

代码语言:javascript
代码运行次数:0
运行
复制
# 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
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-07-04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装
  • 修改位置
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档