在 Ubuntu上安装 Docker

支持的平台

Docker 提供来自以下 Linux 发行版的软件包 和架构:.deb.rpm`

平台 x86_64 / amd64
Ubuntu的
Debian 的
红帽企业 Linux (RHEL)
软呢帽

Docker 在上述发行版的当前 LTS 版本和最新版本上支持 Docker Desktop。随着新版本的推出,Docker 将停止支持最旧的版本,而支持最新版本。

docker安装步骤

卸载旧版本docker

sudo apt-get remove docker docker-engine [docker.io](http://docker.io) containerd runc

更新apt

sudo apt-get update

安装docker依赖环境。

sudo apt-get install ca-certificates curl gnupg lsb-release

添加Docker官方GPG密钥

curl -fsSL [http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg](http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg) | sudo apt-key add -

添加源

sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

安装docker

sudo apt-get install --reinstall docker-ce docker-ce-cli containerd.io

配置用户组

sudo usermod -aG docker $USER

安装工具

sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common

开启网络转发功能

默认会自动开启。
路径 :/proc/sys/net/ipv4/ip_forward
手动开启:

vim /etc/sysctl.conf   #插入以下内容
net.ipv4.forward =1
-------------------------
sysctl -p   #生效
cat /proc/sys/net/ipv4/ip_forward  #查看结果,为1开启成功。

关闭防火墙:

iptables -nL #查看一下iptable规则,关闭防火墙后会自动插入新规则

systemctl stop firewalld && systemctl disable firewalld  #关闭防火墙

sysctlrem restart docker # 关闭防火墙要把docker重启一下,不然docker
的ip包转发功能无法使用。即便防火墙关闭了,docker依旧会调用内核模块netfilter增加规则,所以会新增iptables规则

iptables -nL #再查看一下iptable规则,会发现多出很多规则

iptables -nL

重启docker

service docker restart

验证是否成功

sudo docker run hello-world

启动服务

systemctl start docker && systemctl enable docker

相关推荐

  1. Ubuntu安装 Docker

    2024-07-18 17:40:01       25 阅读
  2. Ubuntu 安装 Docker Engine

    2024-07-18 17:40:01       45 阅读
  3. Docker Ubuntu 安装 Docker 的步骤

    2024-07-18 17:40:01       35 阅读
  4. ubuntu安装docker

    2024-07-18 17:40:01       47 阅读
  5. ubuntu server 22 安装 Docker 引擎

    2024-07-18 17:40:01       31 阅读
  6. Ubuntu 22.04安装Docker最新版本

    2024-07-18 17:40:01       19 阅读
  7. Ubuntu 线 安装 Docker

    2024-07-18 17:40:01       52 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-18 17:40:01       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-18 17:40:01       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-18 17:40:01       58 阅读
  4. Python语言-面向对象

    2024-07-18 17:40:01       69 阅读

热门阅读

  1. 爬虫的概念

    2024-07-18 17:40:01       21 阅读
  2. Vim 高手指南:Linux 环境下的高级使用技巧

    2024-07-18 17:40:01       18 阅读
  3. phpinfo

    2024-07-18 17:40:01       21 阅读
  4. 每天一个数据分析题(四百三十四)- t检验

    2024-07-18 17:40:01       22 阅读
  5. python \uxx字符串转中文

    2024-07-18 17:40:01       18 阅读
  6. Qt 中的多线程管理方法详解及示例

    2024-07-18 17:40:01       17 阅读
  7. Qt QJson组装数据Sig传递

    2024-07-18 17:40:01       19 阅读