首页 > 其他分享 >docker安装

docker安装

时间:2022-10-09 09:45:53浏览次数:36  
标签:centos ce yum docker 安装 Docker latest

1 查看系统内核和系统信息

命令:

uname -r     #查看系统内核版本
cat /etc/os-release  #查看系统版本

示例:

[root@iZ1608aqb7ntn9Z /]# uname -r
4.18.0-193.14.2.el8_2.x86_64
[root@iZ1608aqb7ntn9Z /]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

2 开始安装Docker

2.1 卸载旧版本

命令:

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

示例:

[root@iZ1608aqb7ntn9Z /]# yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine
No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-engine
没有软件包需要移除。
依赖关系解决。
无需任何处理。
完毕!

2.2 下载依赖安装包

yum install -y yum-utils

2.3 配置镜像仓库

#国外的地址
yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo  
    
# 设置阿里云的Docker镜像仓库
yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

示例:

[root@iZ1608aqb7ntn9Z /]# yum-config-manager \
     --add-repo \
     https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
     添加仓库自:https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.rep

2.4 更新yum软件包

yum makecache fast

2.5 下载docker

yum install docker-ce docker-ce-cli containerd.io   # 安装社区版
yum install docker-ee docker-ee-cli containerd.io   # 安装企业版

一般情况下安装社区版

3 启动Docker

命令:

systemctl start docker   # 启动Docker
docker version           # 查看当前版本号,是否启动成功
systemctl enable docker  # 设置开机自启动

示例:

[root@iZ1608aqb7ntn9Z /]# systemctl start docker
[root@iZ1608aqb7ntn9Z /]# docker version
Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:24 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:54:48 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

4 Docker的HelloWorld

命令:

docker run hello-world

示例:

[root@iZ1608aqb7ntn9Z /]# docker run hello-world
Unable to find image 'hello-world:latest' locally  # 本地没有
latest: Pulling from library/hello-world           # pull一个最新版
b8dfde127a29: Pull complete                        # pull成功
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!                                 # 运行结果
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

5 Docker卸载

yum remove docker-ce docker-ce-cli containerd.io  # 卸载依赖
rm -rf /var/lib/docker    # 删除资源  . /var/lib/docker是docker的默认工作路径

6 配置阿里云镜像

6.1 进入阿里云官网,搜索容器镜像服务

 

 

6.2 执行命令

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://axvfsf7e.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

 

标签:centos,ce,yum,docker,安装,Docker,latest
From: https://www.cnblogs.com/wangjinnan97/p/16771058.html

相关文章

  • MobaXterm注册认证版,亲测可用,操作简单(本机已安装python3环境)
    去github地址下下载代码  解压后在该目录下打开CMD执行MobaXterm-Keygen.py<UserName><Version>命令  生成的文件放在安装目录下,我的是免安装版,放在exe同目......
  • mac通过docker一键部署Nexus3
    目录mac通过docker一键部署Nexus3一、前言二、系统配置三、安装步骤1、Dockerhub查看镜像地址2、一键安装2.1、克隆脚本2.2、安装程序2.2.1、程序安装详情2.3、卸载程序2.3......
  • 五款Docker GUI工具
    链接:https://cloud.51cto.com/art/202010/628604.htm你是否还在大量控制台窗口中监控容器,还是对使用终端命令充满热情?而使用Docker的图形用户界面(GUI)工具,则可以更简......
  • Docker Desktop 可以直接启用Kubernetes 1.25 了
    作为目前事实上的容器编排系统标准,K8s无疑是现代云原生应用的基石,很多同学入门可能直接就被卡到第一关,从哪去弄个K8s的环境,DockerDesktop自带了Kubernetes服务,但是......
  • SolidWorks2020下载安装中文版教程,你solidworks安装失败是什么原因?
    SW2020WIN1064位安装步骤: 1.先使用“百度网盘客户端”下载SW20S5_CN_x64安装包到电脑磁盘英文路径文件夹里,并鼠标右击进行解压缩,安装前先断开电脑网络,然后双击打开“......
  • Docker全攻略 pdf
    高清扫描版下载链接:https://pan.baidu.com/s/12tHbxcpr3GrQwj14QXUGUw点击这里获取提取码 ......
  • 脚本之一键安装zabbix监控端
    ZABBIX_VER=5.0URL="https://mirror.tuna.tsinghua.edu.cn/zabbix"FONT=msyhbd.ttcMYSQL_HOST=localhost#MYSQL_HOST=10.0.0.100MYSQL_ZABBIX_USER="zabbix@localhost"#MYSQ......
  • 脚本之一键安装zabbix-agent被监控端
    1、安装zabbix-agent2脚本ZABBIX_SERVER=zabbix.wang.orgZABBIX_VER=5.0URL="https://mirror.tuna.tsinghua.edu.cn/zabbix"./etc/os-releasecolor(){RES_COL=60......
  • Docker技术入门与实战 pdf
    高清扫描版下载链接:https://pan.baidu.com/s/1lzaibnu27OQZ_UgBsiNmdw点击这里获取提取码 ......
  • Docker开发实践 pdf
    高清扫描版下载链接:https://pan.baidu.com/s/1-BEyIUEZKs1c1N7WO0cG5Q点击这里获取提取码 ......