我是靠谱客的博主 善良手套,最近开发中收集的这篇文章主要介绍docker 学习笔记#1,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

安装环境

#1 系统为centos 7

#2 使用远程工具(随意)我用的putty 进行远程连接,操作。

环境查看

#1 系统内核为3.10以上

[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64

#2 系统信息

[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

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

安装

#1 卸载旧版本docker

[root@localhost ~]# yum remove docker 
>                   docker-client 
>                   docker-client-latest 
>                   docker-common 
>                   docker-latest 
>                   docker-latest-logrotate 
>                   docker-logrotate 
>                   docker-engine

 #2 安装需要准备的安装包

[root@localhost ~]# yum install -y yum-utils

#3 设置镜像仓库 

[root@localhost ~]# yum-config-manager 
>     --add-repo 
>     http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  # 镜像源为阿里云镜像源

#4 安装docker

      1)安装最新版本:

[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

   docker-ce  社区版  ee 企业版   一般都使用ce

      2)安装指定版本

           ①:打开docker列表,找到指定的版本

[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
 * extras: mirrors.aliyun.com
docker-ce.x86_64            3:20.10.9-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.8-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.7-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.6-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.5-3.el7                    docker-ce-stable

           ②:下载指定的版本

[root@localhost ~]# yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-compose-plugin

        

要安装特定版本的 Docker Engine,请在 repo 中列出可用版本,然后选择并安装:

包名称 ( docker-ce) 加上版本字符串(第 2 列),从第一个冒号 ( :) 开始,一直到第一个连字符,用连字符 ( -) 分隔。例如,docker-ce-18.09.1

#4 启动docker

[root@localhost ~]# systemctl start docker

#5 测试docker是否安装完成 (命令为查看docker版本,如果有版本表示安装成功)

[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.15
 API version:       1.41
 Go version:        go1.17.9
 Git commit:        fd82621
 Built:             Thu May  5 13:16:58 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.15
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.9
  Git commit:       4433bf6
  Built:            Thu May  5 13:15:18 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.4
  GitCommit:        212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
 runc:
  Version:          1.1.1
  GitCommit:        v1.1.1-0-g52de29d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

#6 测试docker

[root@localhost ~]# docker run hello-word
Unable to find image 'hello-word:latest' locally
docker: Error response from daemon: pull access denied for hello-word, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

如果出现上述错误,可以试着用以下方式解决:

#1 安装系统工具

yum install -y yum-utils device-mapper-persistent-data lvm2

#2 添加阿里云软件源

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#3 更新yum缓存

yum makecache fast

#4 测试hello-word

docker run hello-world

 以上为学习笔记,仅供参考!!!

最后

以上就是善良手套为你收集整理的docker 学习笔记#1的全部内容,希望文章能够帮你解决docker 学习笔记#1所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部