linux安装docker
admin
2024-05-21 07:38:06

linux安装docker

安装环境

执行命令,查看linux的系统内核,并且根据linux内核下载对应版本docker 安装包

uname -r

下载地址

官方下载linux

官方其他版本

在线安装

  • 查看是否安装docker

    yum list installed | grep docker
    
  • 安装docker

    yum -y install docker
    

离线安装

  1. 先下载对应安装包,解压

    tar -zxvf docker-20.10.19.tgz
    
  2. 将解压内容复制到/usr/bin

    cp docker/* /usr/bin
    
  3. /usr/lib/systemd/system目录下新增docker.service文件,并建立软连接,内容如下,注意:insecure-registry要改成自己的ip

    • 建立连接

      ln -s  '/usr/lib/systemd/system/docker.service'  '/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
      
    • 这个是正常linux的文件内容

      [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 --selinux-enabled=false --insecure-registry=127.0.0.1
      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
      
  4. docker.service添加权限

    chmod a+x /etc/systemd/system/docker.service
    
  5. 重新加载配置文件

    systemctl daemon-reload  
    
  6. 启动/重启/查看状态

    systemctl  start/stop/restart/status docker
    
  7. 设置开机启动

    systemctl enable docker.service
    

使用docker

配置镜像下载地址

vi /etc/docker/daemon.json 
# 下面是镜像地址,配置这个,加快下载速度
{"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn"]
}

相关内容

热门资讯

奥地利小镇邂逅农民思想家多伊布... 旅游奥地利期间,每天与同行的徐静波教授晨起一同散步,有时沿着多瑙河,有时在维也纳的森林间,但给我印象...
读懂济南|从“一阵风”到“长红... 齐鲁晚报·齐鲁壹点 王贝艺大明湖畔的狂欢还未收尾,五龙潭的泼水狂欢又已开场;广智里的咖啡香还没散尽,...
黄河壶口瀑布水量大增 形成壮美...   9月9日,受降雨天气影响,位于晋陕峡谷的黄河壶口瀑布水量大增,主副瀑布连成一片,形成壮美瀑布群景...
“请3休13”点燃中秋国庆国内... 财联社9月10日讯(记者 胡皓琼)中秋前一日火车票开售,中秋国庆国内游预订提速。财联社记者从OTA平...
微言|游客暴增却带不来利润?“... 中秋、国庆假期将至,很多地方将迎来旅游旺季。然而,一些地方旅游人次创新高,民宿经营者却普遍反映利润摊...