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"]
}

相关内容

热门资讯

“六一”亲子游热度飙升,成年子... “六一”国际儿童节即将来临,不少家庭游客已提前预订亲子旅游产品,根据同程旅行、去哪儿、途牛等OTA(...
柯尔鸭花车、科学魔法秀、卡皮巴... 华声在线5月28日讯(全媒体记者 曾冠霖)六一儿童节临近,长沙亲子游市场持续升温。5月28日,记者从...
“六一”儿童节去哪玩?广西各大... “六一”国际儿童节临近,广西各大景区、场馆推出门票优惠与丰富的亲子活动,涵盖山水休闲、萌宠互动、非遗...
旅行社责任险报价:一年几千元,... 旅行社问责任险报价时,很多人第一反应是:"一年多少钱?最低能做到多少?"但在保游网看来,旅行社责任险...