liujiusheng / blog

个人博客,blog
19 stars 0 forks source link

CentOS7精简版Docker安装 #166

Open liujiusheng opened 4 years ago

liujiusheng commented 4 years ago

CentOS7精简版安装之后默认是没启动网卡的,所以首先是要配置网卡。 打开配置文件:vi /etc/sysconfig/network-scripts/ifcfg-ens33 修改ONBOOT值为yes 保存 重启网卡:service network restart ip addr命令可查看当前Ip地址

到这个地址下载最新的安装包: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

放到centos上之后:yum install ./docker安装包.rpm就安装成功了。 新版的好像安装成功之后自己就启动Docker了,跟官方文档上写得不大一样。

docker的镜像管理跟git的管理差不多,可以直接从仓库下载现成可用的镜像,最大的镜像仓库就是docker.hub。然而由于墙的问题它下载很慢,所以可以到阿里云上申请一个镜像加速的地址使用。 然后在/etc/docker/daemon.json文件里配置上 { "registry-mirrors":["https://ka7kmrnv.mirror.aliyuncs.com"] } 这一句内容就可以了(docker文件夹可能没有,需要自己创建)。

创建/usr/lib/systemd/system/docker.service文件:

[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

ExecStart=/usr/bin/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

还没成功

Docker安装官方文档: https://docs.docker.com/install/linux/docker-ce/centos/

参考: https://blog.csdn.net/c851204293/article/details/89312139