非root安装docker
添加docker组
cat /etc/group |grep docker
sudo groupadd docker
sudo gpasswd -a 用户名 docker
下载docker源码
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-18.09.0.tgz
解压缩
tar -zxvf docker-18.09.0.tgz
sudo cp docker/* /usr/bin/
#docker有关指令的所属用户和所属组(必做,不然非root用户使用docker指令报错:权限不够)
sudo chown root:docker /usr/bin/docker*
sudo chown root:docker /usr/bin/containerd*
sudo chown root:docker /usr/bin/runc
sudo chown root:docker /usr/bin/ctr
查看下
设置docker服务
新建
sudo vi /etc/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
添加权限
sudo chmod a+x /etc/systemd/system/docker.service
sudo systemctl daemon-reload
镜像加速
新建
sudo vi /etc/docker/daemon.json
添加以下内容
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
启动docker
sudo systemctl start docker
附
启/停/重启/查看状态
sudo systemctl start/stop/restart/status