Docker安装
编辑
30
2024-10-28

前排声明:文章方法部分为google得来,个人操作成功后汇总发出
常规安装
tar下载和解压
wget https://download.docker.com/linux/static/stable/x86_64/docker-26.0.0.tgz
传到你想要的目录,可能是/soft
tar -zxvf docker-26.0.0.tgz
cp -p docker/* /usr/bin
注册服务
vi /etc/systemd/system/docker.service
chmod +x /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
# 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 tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
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
cd /etc/systemd/system
systemctl daemon-reload
启动Docker并设置开机自启
systemctl start docker
systemctl enable docker.service
验证
docker run hello-world
如果出现问题
可能在systemctl start docker 会出现问题,查看日志也并不能解决,这时候如果有外网 ,换一种操作形式
确认yum源
首先确认是否有可用的yum源来进行依赖的安装,如果没有,请google寻找
https://blog.csdn.net/hanzheng260561728/article/details/51035629
#oracle linux 8
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
oracle linux各个版本的yum源
yum repoinfo
如果缺少DNS解析
可以重启网卡的情况:
vi /etc/sysconfig/network-scripts/ifcfg-ens33
修改网卡配置文件,加一条DNS=8.8.8.8
#临时指定解析指定网站使用某DNS
dig @8.8.8.8 get.docker.com
不重启网卡:
这时使用一键命令安装可能还是会出现解析问题,这时可以修改临时文件,无需重启网卡
vi /etc/resolv.conf
加一行
nameserver 8.8.8.8
安装依赖(实际上一键安装就不需要了)
yum install -y yum-utils
一键安装命令
curl -fsSL https://get.docker.com | bash -s docker
oracle linux不支持docker此命令的一键安装,此处骚操作:
报错内容:
Executing docker install script, commit:442e66405c304fa92af8aadaa1d9b31bf4b0ad94
ERROR: Unsupported distribution 'ol'
更改/etc/os-release文件的ID属性,orcacle linux 为ol,修改为centos即可
- 0
- 0
-
分享