Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

centos7官方docker安装[0]

Posted on 2023年11月14日2025年5月6日 by

本安装教程也适用于centos8stream

docker的安装方式有很多种,本篇是docker官方的安装方式。

  • 移除可能的docker旧版本
yum remove docker \
                 docker-client \
                 docker-client-latest \
                 docker-common \
                 docker-latest \
                 docker-latest-logrotate \
                 docker-logrotate \
                 docker-engine
  • 开始安装
yum install -y yum-utils

yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

yum install docker-ce docker-ce-cli containerd.io
  • 启动docker
systemctl start docker
  • 另外一种安装方式——官方一键安装
wget -qO- get.docker.com | bash
systemctl start docker

 

  • docker的防火墙问题

实际部署发现,docker可以绕过firewalld的管理,直接开通iptables的规则,并且在firewall-cmd 上无法实现管理,原因时docker直接在iptables上添加了规则和路由。

1)查看pulic规则

firewall-cmd --list-all

使得主机的ip能够直接访问docker镜像所在的ip

2)查看docker新建的防火墙区域

firewall-cmd --get-active-zones

3)docker区域的接口

firewall-cmd --list-all --zone=docker

从上图可以看出,docker并没有在firewalld上新建规则

4)查询docker的网络

docker network ls

docker镜像创建了4个本地可以访问的网桥

5)iptables上的规则

iptables介绍详见此

iptables -L DOCKER

host上的特定端口被docker镜像所在的内网ip接管特定的接口,上图标识了协议和用途

iptables -nL DOCKER

上图更加详细的显示了占用的端口

6)查看所有的iptables的表

iptables --list

iptables -L -n

docker实际开启的端口,这些端绕开firewalld的管理,直接在iptables上实现接管

7)查看docker的状态

systemctl status docker

 

8)临时处理方式

实际测试时,存在iptables修改后,重启设置生效的问题,但是iptables删除某条规则后理解生效。因此可以删除掉特定的规则,而不重启。

 

防火墙问题导致docker镜像无法访问,处理如下:

firewall-cmd --permanent --zone=trusted --add-interface=docker0
firewall-cmd --reload

 

 

参考资料:

  1. https://docs.docker.com/engine/install/centos/

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT