linux下docker安装
docker下载地址
https://download.docker.com/linux/static/stable/x86_64/
下载安装
wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.6.tgz
tar -zvxf docker-19.03.6.tgz
cp docker/* /usr/bin/
直接运行
/usr/bin/dockerd
demon模式运行,并保存日志
nohup /usr/bin/dockerd >/docker.log 2>&1 &
systemctl运行
sudo vim /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
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
设置权限权限为可执行
chmod +x /etc/systemd/system/docker.service
添加阿里云镜像j
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://zxnkv11f.mirror.aliyuncs.com"]
}
EOF
常用命令
systemctl daemon-reload //重载配置文件
systemctl start docker //启动Docker
systemctl stop docker //关闭docker
systemctl restart docker //重启docker
systemctl enable docker.service //设置开机自启
systemctl status docker //查看Docker状态
很多时候在我们挂载磁盘后不想用docker默认目录 可 -g 修改目录 (docker 默认目录在/var/lib/docker下,包括 pull下来的镜像都在该目录下)
ExecStart修改为:
ExecStart=/usr/bin/dockerd -g /xiaobo/docker
脚本安装docker
#/bin/bash
wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.6.tgz
tar -zvxf docker-19.03.6.tgz
cp docker/* /usr/bin/
cat > /etc/systemd/system/docker.service << EOF
[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
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
chmod +x /etc/systemd/system/docker.service
mkdir -p /etc/docker/
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://zxnkv11f.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl start docker
systemctl enable docker.service
systemctl status docker
作者:南辞、归
本博客所有文章仅用于学习、研究和交流目的,欢迎非商业性质转载。
博主的文章没有高度、深度和广度,只是凑字数。由于博主的水平不高,不足和错误之处在所难免,希望大家能够批评指出。
博主是利用读书、参考、引用、抄袭、复制和粘贴等多种方式打造成自己的文章,请原谅博主成为一个无耻的文档搬运工!