docker基础——CentOS7安装Docker CE

Install Docker CE
Install using the repository
SET UP THE REPOSITORY
1.Install required packages.  yum-utils  provides the  yum-config-manager  utility, and  device-mapper-persistent-data  and  lvm2 are required by the  devicemapper  storage driver.

sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

2. Use the following command to set up the  stable  repository. You always need the  stable  repository, even if you want to install builds from the  edge  or  test  repositories as well.

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3. Optional : Enable the  edge  and  test  repositories. These repositories are included in the  docker.repo  file above but are disabled by default. You can enable them alongside the stable repository.

sudo yum-config-manager --enable docker-ce-edge

sudo yum-config-manager --enable docker-ce-test


INSTALL DOCKER CE
1. Install the  latest version  of Docker CE, or go to the next step to install a specific version:

sudo yum install docker-ce


2. Start Docker.
sudo systemctl start docker
3. centos7中修改docker默认保存位置 编辑 /usr/lib/systemd/system/docker.service

默认存储路径为系统盘,我们需要重新指定存储位置到 /app/docker
ExecStart 后面添加 --graph /app/docker
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required


# for containers run by docker
#change storage dir to /app/docker --graph /app/docker
ExecStart=/usr/bin/dockerd --graph /app/docker


ExecReload=/bin/kill -s HUP $MAINPID

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

4.重启docker
sudo systemctl stop docker
sudo systemctl start docker
5.查看是否生效
docker info
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 18.04.0-ce
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 logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-693.2.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.702GiB
Name: iZ2zehvphr2ekybxy7u5c6Z
ID: EEOF:JEMI:CMRQ:TCZF:QJ53:B7F3:BBRS:4U2Y:G6W3:HLX4:NHFG:BKDL
Docker Root Dir: /app/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

猜你喜欢

转载自blog.csdn.net/shnsuohaonan/article/details/80662782
今日推荐