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

Docker教程第六章:安装-Docker引擎版本(centos)

nanshan 2024-10-12 05:37 10 浏览 0 评论

准备

安装docker引擎需要Centos 7或者 8版本,系统必须启用centos-extras存储库。这个存储库在默认情况下是启用的,但是如果您已经禁用了它,则需要重新启用它,建议使用overlay2存储驱动,执行如下命令卸载老版本docker引擎,/var/lib/docker/下存储了老的镜像、挂载卷、容器等文件如果不需要建议删除

 sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

安装方式一共三种:

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


采用仓库安装

安装工具

$ sudo yum install -y yum-utils

配置仓库源

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

安装引擎

查看指定版本

$ yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64  3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64  3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64  18.06.1.ce-3.el7                    docker-ce-stable

最新版本安装

$ sudo yum install docker-ce docker-ce-cli containerd.io

基于版本安装

$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

启动服务

 sudo systemctl start docker

验证安装

使用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/


采用安装包

如果无法使用 仓库 进行安装,可以采用下载安装包(.rpm)的形式进行安装

下载安装包

根据CentOS版本在https://download.docker.com/linux/centos/ 选择相应的docker 引擎版本下载

安装引擎

 $ sudo yum install /path/to/package.rpm

启动服务

sudo systemctl start docker

验证安装

使用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/


更新镜像

如果要升级Docker引擎,请下载更新的软件包文件,然后重复安装过程,使用yum -y upgrade代替yum -y install,并指向新文件。


脚本安装

Docker 官方为了简化安装流程,提供了一套安装脚本,但是不建议将便利脚本用于生产环境。该脚本的源代码是开源的,可以在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概念

相关推荐

Linux下C++访问web—使用libcurl库调用http接口发送解析json数据

一、背景这两天由于一些原因研究了研究如何在客户端C++代码中调用web服务端接口,需要访问url,并传入json数据,拿到返回值,并解析。 现在的情形是远程服务端的接口参数和返回类型都是json的字符...

干货 | 这 3 个超经典的Linux实战项目,让你分分钟入门Linux系统

编译安装nginx搭建小游戏网站编译安装流程下载nginx代码wget-P/server/tools/http:nginx.org/download/nginx1.22.0.tar.gz解压并进...

权限管理-树莓派linux⑦

前言当你在看这篇README,我感到非常荣幸。作为支持开源、分享的理念的我,给大家带来一些学习上的乐趣。由于本人并非专业的教育领域人士,很多时候天马行空,随心所欲的表达方式,可能让部分人感到不适。请根...

每天Linux学习:linux文件属性

ls-lih先通过这个命令来观察(-l列表显示目录内容详细,-i第一列显示inode,-h将文件大小显示为我们常见的kb,mb等单位)从截图中我们能看出文件属性由这9列信息组成:第1列:inod...

Linux ln、unlink命令用法

ln命令可以用来创建软链接或硬链接。1.创建软链接:ln-s源文件目标文件例如:ln-s/usr/lib/libc.so/usr/local/lib/libc.so.6这样就创建了一...

Linux 系统启动完整流程

一、启动系统流程简介如上图,简述系统启动的大概流程:1:硬件引导UEFi或BIOS初始化,运行POST开机自检2:grub2引导阶段系统固件会从MBR中读取启动加载器,然后将控制权交给启动加载器GRU...

最火的 CI/CD 平台 Jenkins 详细搭建教程(for Linux)

在正式学习Jenkins之前我们需要对两个名词有一定了解,其一是DevOps,另外一个就是CI/CD。何为DevOps?来自wiki百科介绍DevOps是一系列软件开发实践,强调开发人员(Dev)和测...

hadoop集群搭建详细方法

第一步:搭建配置新的虚拟机格式化之前先把tmp目录下所有与Hadoop有关的信息全部删除rm-rf/tmp/hadoop-centos*开启之后jps只有Java的进程:sudovi/et...

Linux 常用命令集合

系统信息arch显示机器的处理器架构(1)uname-m显示机器的处理器架构(2)uname-r显示正在使用的内核版本dmidecode-q显示硬件系统部件-(SMBIOS/DM...

inode文件索引,你了解嘛?你的Linux基础真的扎实嘛?

一、inode是什么?深入了解inode,就要从文件存储说起来!文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector)。每个扇区储存512字节。读取硬盘的时候,不会一个个扇区地读取,这样效率...

linux实例之创建service服务

前面我们讲过可以通过service命令来启动,重启,停止指定的服务程序。service服务可以在系统启动时,自动运行该服务,我们可以利用这一特点,创建service文件,并且让系统重启时,自动执行命令...

linux之软连接和硬连接的区别

硬连接硬链接是通过索引节点进行的链接。在Linux中,多个文件指向同一个索引节点是允许的,像这样的链接就是硬链接。硬链接只能在同一文件系统中的文件之间进行链接,不能对目录进行创建。如果删除硬链接对应的...

Linux inode 详解

简介索引节点(IndexNode)是Linux/类unix系统文件系统上的一种数据结构,用于存储有关文件或目录的元数据。它包含文件的所有信息,除了文件名和数据。inode在文件系统如何存储和检...

Bash 脚本实例:获取符号链接的目标位置

我们都熟悉Linux中的符号链接,通常称为符号链接或软链接,符号链接是指向任何文件系统中的另一个文件或目录的特定文件。本文将介绍Linux中符号链接的基础知识,并创建一个简单的bash脚本...

windows快捷方式,符号链接,软链接和硬链接

当一个软件大量的向C盘写入数据,而我们又无法修改软件保存数据的位置时,可以使用windows系统的“符号链接”(SymbolicLink)功能,将保存数据的位置修改到其它分区中。符号链接类似于我们熟...

取消回复欢迎 发表评论: