百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

Docker教程第五章:安装-Docker引擎版本(ubuntu)

nanshan 2024-11-04 13:03 17 浏览 0 评论

准备

环境要求,需要一个64bit 的ubuntu系统,Docker Engine支持x86_64(或amd64)、armhf、arm64和s390x架构, 引擎支持overlay2, aufs and btrfs存储驱动,且docker引擎默认支持overlay2。支持ubuntu 版本如下:

  • Ubuntu Impish 21.10
  • Ubuntu Hirsute 21.04
  • Ubuntu Focal 20.04 (LTS)
  • Ubuntu Bionic 18.04 (LTS)

执行如下命令卸载老版本docker引擎,/var/lib/docker/下存储了老的镜像、挂载卷、容器等文件如果不需要建议删除

sudo apt-get remove docker docker-engine docker.io containerd runc

安装方式一共三种:

  • 仓库方式安装
  • 安装包方式安装
  • 脚本安装


采用仓库安装

安装工具

$ sudo apt-get update
$ sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

添加GPG秘钥

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gp

配置仓库源

 $ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

安装引擎

查看指定版本

apt-cache madison docker-ce

最新版本安装

 $ sudo apt-get update
 $ sudo apt-get install docker-ce docker-ce-cli containerd.io

基于版本安装

 sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

验证安装

使用docker 运行hello-world镜像

banbohub@banbohub .~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
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/

更新镜像

运行sudo apt-get update 根据相应说明进行升级,或者卸载后重新安装部署

采用安装包

如果无法使用ubuntu repository 进行安装,可以采用下载安装包(.deb)的形式进行安装

下载安装包

根据ubuntu版本,以及处理器架构(amd64, armhf, arm64, 活着 s390x)在https://download.docker.com/linux/ubuntu/dists/选择相应的docker 引擎版本下载

安装引擎

 sudo dpkg -i /path/to/package.deb

验证安装

使用docker 运行hello-world镜像

banbohub@banbohub .~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
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/D: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/

更新镜像

需要重新下载新版本的安装包卸载,老版本后重新安装

脚本安装

Docker 官方为了简化安装流程,提供了一套安装脚本,Ubuntu 和 Debian 系统可 以使用这套脚本安装,但是不建议将便利脚本用于生产环境。该脚本的源代码是开源的,可以在GitHub上的docker安装存储库中找到。

$ curl -fsSL https://get.docker.com -o get-docker.sh 
$ sh ./get-docker.sh

省略sudo

创建 docker 用户组

sudo groupadd docker

将用户添加到 docker 组

sudo usermod -aG docker {your_username}

相关推荐

Docker教程第四章:Docker概念

Docker教程第三章:Docker架构

Docker教程第二章:Docker生态


Docker教程第一章:Docker介绍

相关推荐

Centos7虚拟机安装及网络配置(二)

#二、centos7的网络配置-Nat模式NAT模式也是VMware创建虚拟机的默认网络连接模式。使用NAT模式网络连接时,VMware会在主机上建立单独的专用网络,用以在主机和虚拟机之间相互通信。虚...

网络分析shell脚本(实时流量+连接统计)

介绍一个强大的分析网络的shell脚本,此脚本是从EZHTTP拆分出来的,觉得有必要单独介绍下。脚本运行效果截图:此脚本包含的功能有:1、实时监控任意网卡的流量2、统计10秒内平均流量3、统计每个端口...

Centos之Could not retrieve mirrorlist解决方案

Centos之Couldnotretrievemirrorlist解决方案:vi/etc/sysconfig/network-scripts/ifcfg-你的网卡名字修改:ONBOOT=ye...

一文掌握!VirtualBox 中 Rock9.x(Linux)网络配置全攻略

一、前言记得我有一篇文章《必看!VirtualBox中Centos7(Linux)网络配置全攻略》讲的非常明细,但是因为CentOS已经停止维护了,可能很多人都不想继续学CentOS,我也是一样,...

CentOS 6.0 设置IP地址、网关、DNS

在做任何操作之前先备份原文件,我们约定备份文件的名称为:源文件名称+bak,例如原文件名称为:centos.txt那么备份文件名称为:centos.txtbak引言:linux的网卡IP地址是存放在文...

Linux CentOS 基础操作(centos怎么操作)

简介:养成学习Linux的好习惯,第一是多查看manpage(manual)等帮助文档和利用好Tab键;第二是掌握好一些快捷键,比如ctrl+c(停止当前进程),ctrl+r(查看命令历史)...

Linux抓包王者技能!这条命令直接封神,教你精准定位网络问题

在网络故障排查和性能调优中,抓包是一项必不可少的技能。对于Linux环境下的网络工程师和运维人员来说,掌握高效抓包方法至关重要。而要说“抓包界的王炸”,那非tcpdump莫属!今天,我们不仅要介绍...

「干货」如何在 Linux 上划分VLAN?

在某些场景中,我们希望在Linux服务器(CentOS/RHEL)上的同一网卡分配来自不同VLAN的多个ip。这可以通过启用VLAN标记接口来实现,但要实现这一点,首先必须确保交换机上添加多个vl...

CentOS 8 网络配置实战教程:静态IP、路由与DNS设置

一、配置前准备1.查看当前网络信息#查看所有网络接口nmclidevicestatus#查看指定网卡信息(假设网卡名为ens192)ipaddrshowens192#查看路由...

Debian10.7修改网络配置(debian怎么配置网络)

简介:关于Debian获取IP地址的方法主要有两种,动态获取和静态设置。在配置网络之前先要知道Debian的网卡名称是什么,Debian可通过命令#ipa查看网卡名称。本文主要通过介绍Debian...

巧用SSH转发功能深入穿透内网(ssh转发udp)

ssh能够提供客户端到服务端的加密传输,当http、ftp等协议被防火墙所拦截时,可以考虑使用SSH的端口转发功能,将其它TCP端口的网络数据通过SSH连接来转发。转发方式一共有三种,分别是:动态转发...

CentOS Linux 7 的IP地址配置(centos7.4配置ip地址)

前段时间有位朋友,在一台PC机上安装了CentOSLinux7系统,因为要接入局域网,需要配置IP地址和默认网关信息。于是参照一本Linux教程上编辑网卡配置信息的方法,输入:vim/etc/s...

教你如何在 Linux 上划分VLAN(linux怎么分区详解)

在某些场景中,我们希望在Linux服务器(CentOS/RHEL)上的同一网卡分配来自不同VLAN的多个ip。这可以通过启用VLAN标记接口来实现,但要实现这一点,首先必须确保交换机上添加多个vl...

打通数据高速公路:如何在 CentOS 上使用 Thunderbolt 3 和 4

Thunderbolt3与4是现代高速外设连接的代表,带来了40Gbps的惊人带宽,支持数据、视频、音频与供电的“四合一”功能,尤其在专业视频编辑、科研计算、虚拟化扩展等领域具有巨大价值...

VMware 虚拟机 CentOS7 桥接模式静态 IP 配置全攻略

虚拟机桥接模式原理配置成桥接网络连接模式的虚拟机就当作主机所在以太网的一部分,虚拟系统和宿主机器的关系,就像连接在同一个Hub上的两台电脑,可以像主机一样可以访问以太网中的所有共享资源和网络连接,可以...

取消回复欢迎 发表评论: