码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • docker安装及使用-Linux


    前提

    确保docker支持当前系统版本,docker支持centos 7及以上版本,要求Linux内核版本不低于3.10

    cat /etc/redhat-release        #查看系统版本

    查看内核版本三种方式

    cat /proc/version

    uname -a

    uname -r

    一、安装docker

    0、卸载docker(根据需要执行)

    yum remove docker \

    docker-client \

    docker-client-latest \

    docker-common \

    docker-latest \

    docker-latest-logrotate \

    docker-logrotate \

    docker-selinux \

    docker-engine-selinux \

    docker-engine \

    docker-ce

    1、确保虚拟机联网

    centos安转完不能连网怎么解决

    2、安装软件包(包、仓库、依赖管理器)

    #yum-utils提供了yum-config-manager,并且device mapper存储驱动程序需要device-mapper-persistent-data和lvm2

    yum install -y yum-utils

    yum install -y device-mapper-persistent-data

    yum install -y lvm2

    3、设置docker仓库

    #使用yum-config-manager命令(上一步安装的)

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

    4、安装社区版docker

    yum install -y docker -ce / yum --config=/etc/yum.conf install docker-ce

    等待安装完成,使用docker -v查看docker版本

    二、使用docker

    1、关闭防火墙

    #由于docker需要用到很多端口

    systemctl stop firewalld

    systemctl disable firewalld #禁止开机自启

    systemctl status firewalld #查看是否关闭防火墙

    2、启动docker服务

    systemctl start docker

    systemctl stop docker #停止

    systemctl restart docker #重启

    3、配置docker镜像加速

    Docker配置阿里镜像加速源,超详细_docker 加速源_神奇的海马体的博客-CSDN博客

    mkdir -p /etc/docker && cd /etc/docker

    vi daemon.json

    {
        "registry-mirrors": [ 
            "https://docker.mirrors.ustc.edu.cn" 
        ]
    }

    systemctl daemon-reload #重新加载文件

    systemctl restart docker #重启docker

    过程中遇到的问题及解决方法

    Q:执行 yum-config-manager —add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 报错 /usr/lib/python2.7/site-packages/yum/misc.py:133: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal return lambda s: s.lower() == pat

    A:由于 Python 2.7 版本对 Unicode 字符处理的问题导致的。在 Python 2.7 中,当进行 Unicode 字符比较时,如果其中一个字符无法转换为 Unicode,则会引发 UnicodeWarning。

    为了解决这个问题,你可以尝试以下方法:

    1、在命令行中设置环境变量:在运行 yum-config-manager 命令之前,在命令行中设置 PYTHONWARNINGS="ignore:UnicodeWarning" 环境变量,例如:

    PYTHONWARNINGS="ignore:UnicodeWarning" yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    

    这将临时禁用 Unicode 警告,使命令可以正常执行。

    2、使用 Python 3 运行 yum-config-manager:如果你的系统上同时安装了 Python 2 和 Python 3,可以尝试使用 Python 3 来运行 yum-config-manager 命令。例如:

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

    这样可以避免 Python 2.7 的 Unicode 处理问题。

    Q:docker pull image_name 报错 Error response from daemon: pull access denied for python3, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

    A:docker info 查看 registry_url 然后登录docker

    docker login --username --password

    Centos7配置Docker镜像加速器(报错Error response from daemon: pull access denied for centos7, repository does )_小于同学不想卷的博客-CSDN博客

    docker拉取镜像时报错:docker: Error response from daemon: Get “https://registry-1.docker.io/v2/“: dial tcp:_王祺灏的博客-CSDN博客

    最终使用该方式解决:修改文件 vi /etc/resolv.conf

    注释掉:nameserver 192.168.100.2
    新增DNS:nameserver 114.114.114.114 nameserver 8.8.8.8

  • 相关阅读:
    json-server库的使用,实现数据模拟
    深入了解“注意力”和“变形金刚” -第1部分
    Apache Spark 的基本概念和在大数据分析中的应用
    ViT模型中的tokens和patches概念辨析
    C语言详解——操作符讲解
    Day719. 矢量运算 -Java8后最重要新特性
    C#基础--运算符和类型强制转换
    RestoreDet
    数据结构之栈和队列以及如何封装栈和队列,栈和队列的实例(进制转换和击鼓传花)
    Java网络编程-IO模型篇之从BIO、NIO、AIO到内核select、epoll剖析!
  • 原文地址:https://blog.csdn.net/qq_42108192/article/details/132577495
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号