赞
踩
目录
在Linux上安装docker 需要centos7及以上版本才可以;
https://docs.docker.com/engine/install/centos/
- [root@localhost ~]# uname -r
- 3.10.0-957.el7.x86_64
- [root@localhost ~]#
- [root@localhost ~]#
- [root@localhost ~]#
- [root@localhost ~]# uname -r
- 3.10.0-957.el7.x86_64
- [root@localhost ~]# ^C
- [root@localhost ~]# cat /etc/os-release
- NAME="CentOS Linux"
- VERSION="7 (Core)"
- ID="centos"
- ID_LIKE="rhel fedora"
- VERSION_ID="7"
- PRETTY_NAME="CentOS Linux 7 (Core)"
- ANSI_COLOR="0;31"
- CPE_NAME="cpe:/o:centos:centos:7"
- HOME_URL="https://www.centos.org/"
- BUG_REPORT_URL="https://bugs.centos.org/"
-
- CENTOS_MANTISBT_PROJECT="CentOS-7"
- CENTOS_MANTISBT_PROJECT_VERSION="7"
- REDHAT_SUPPORT_PRODUCT="centos"
- REDHAT_SUPPORT_PRODUCT_VERSION="7"
- yum remove docker \
- docker-client \
- docker-client-latest \
- docker-common \
- docker-latest \
- docker-latest-logrotate \
- docker-logrotate \
- docker-engine
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
- docker version
- docker run hello-world
- docker images
- mkdir -p /etc/docker
- cat > /etc/docker/daemon.json <<'EOF'
- {
- "exec-opts": ["native.cgroupdriver=systemd"],
- "log-driver": "json-file",
- "log-opts": {
- "max-size": "100m"
- },
- "storage-driver": "overlay2"
- }
- EOF
- systemctl restart docker
下载地址:Index of linux/static/stable/x86_64/
我这里下载的是docker-19.03.9.tgz ,一般我们需要下载社区版 -ce ;
cmd命令:
scp -r C:\Users\small\Downloads\docker-19.03.9.tgz root@192.168.150.20:/opt/
进入opt目录解压docker-19.03.9.tgz
tar -zxvf docker-19.03.9.tgz
cp -p docker/* /usr/bin
在/usr/lib/systemd/system/目录下,创建docker.service文件
编辑docker.service文件
vi /usr/lib/systemd/system/docker.service
复制内容到docker.service中
- [Unit]
- Description=Docker Application Container Engine
- Documentation=http://docs.docker.com
- After=network.target docker.socket
- [Service]
- Type=notify
- EnvironmentFile=-/run/flannel/docker
- WorkingDirectory=/usr/local/bin
- ExecStart=/usr/bin/dockerd \
- -H tcp://0.0.0.0:4243 \
- -H unix:///var/run/docker.sock \
- --selinux-enabled=false \
- --log-opt max-size=1g
- 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=on-failure
- [Install]
- WantedBy=multi-user.target
重新加载某个服务的配置文件,如果新安装了一个服务,归属于 systemctl 管理,要是新服务的服务程序配置文件生效,需重新加载。
systemctl daemon-reload
systemctl start docker
systemctl status docker
systemctl enable docker
docker version
到此docker离线版就部署完成!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。