Docker-install
1、Docker安装
docker-ce-cli下载地址:
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce-cli_19.03.15~3-0~ubuntu-bionic_amd64.deb
https://hub.docker.com/
Redhat、Debian、Fedora,甚至是还支持了Mac和 Windows,在linux系统上需要内核版本在3.10或以上,docker版本号之前一直是0版本或1.X 之后的版本之后开始区分为CE版本(社区版本)和EE(企业收费版)
官方rpm包下载地址:
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
172.31.7.101-centos7.8-docker的安装:
------------------------------------
https://mirrors.tuna.tsinghua.edu.cn/
Uninstall old versions 卸载旧docker
# yum remove docker docker-common docker-selinux docker-engine
安装一些依赖
# yum install -y yum-utils device-mapper-persistent-data lvm2
根据你的发行版下载repo文件
# wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
把软件仓库地址替换为 TUNA
# sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
最后安装:
# yum makecache fast
# yum install docker-ce -y
启动docker
# systemctl enable -now docker
查看docker版本信息
# docker --version
# docker version
172.31.7.13-Debian/Ubuntu1804 安装docker
-----------------------------------------
如果你过去安装过 docker,先删掉:
# apt-get remove docker docker-engine docker.io
首先安装依赖:
# apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
信任 Docker 的 GPG 公钥:
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
对于 amd64 架构的计算机,添加软件仓库:
# echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
查看仓库有的docker版本
# apt-cache madison docker-ce
最后安装:
# apt-get update
下载指定版本的docker
# apt install docker-ce=5:19.03.15~3-0~ubuntu-bionic
下载docker的命令行工具
方法一:
# apt docker-ce-cli=5:19.03.15~3-0~ubuntu-bionic
方法二:
# wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce-cli_19.03.15~3-0~ubuntu-bionic_amd64.deb
# dpkg -i docker-ce-cli_19.03.15~3-0~ubuntu-bionic_amd64.deb
查看docker具体详细信息
# docker info
下载镜像
# dr pull nginx
前台运行nginx服务
# dr run -it -p 8888:80 nginx
访问:
http://172.31.7.14:8888/
查看iptables规则
# iptables -t nat -vnL
2 104 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 to:172.17.0.2:80
172.31.7.15-Debian/Ubuntu1804 docker二进制安装
---------------------------------------------
# cd /usr/local/src
# wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-19.03.15.tgz
# tar xvf docker-19.03.15.tgz
查看下载的源码版本号
# ./docker/docker --version
Docker version 19.03.15, build 99e3ed8
考到/usr/bin/中保证普通用户能够执行
# cp /usr/local/src/docker/* /usr/bin
1.创建服务启动文件:
# vim /lib/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
启动服务
# systemctl enable containerd && systemctl start containerd && systemctl status containerd
2.创建docker配置文件:
# vim /lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[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/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# 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
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# 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
[Install]
WantedBy=multi-user.target
3.配置docker-socket文件:
# vim /lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
启动docker:
# groupadd docker
# systemctl start docker docker.socket
# docker info
172.31.7.16 脚本二进制安装docker``
-------------------------------
D:\和彩云同步文件夹\scripte file\Docker-通用安装\docker-不联网二进制部署\docker-19.09.15-binary-install.tar.gz
上传此文件docker-19.09.15-binary-install.tar.gz
# tar xvf docker-19.09.15-binary-install.tar.gz
# cd zhgedu
# bash docker-install.sh
完成安装
解决不支持swap限制警告:
# vim /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 cgroup_enable=memory swapaccount=1"
#开启交换分区的资源限制,限制虚拟机能使用多少交换分区
# update-grub
# reboot
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具