首页 > 系统相关 >在centos 7上部署安装docker

在centos 7上部署安装docker

时间:2022-11-25 09:00:16浏览次数:55  
标签:centos 部署 ce yum Docker com docker

一、docker概述

docker资源地址

官网:https://www.docker.com/ 文档地址:https://docs.docker.com/ 仓库地址:https://hub.docker.com/

镜像(images):

docker镜像就好比是一个模板,可以通过这个模板来创建容器服务,eg:tomcat镜像====>>run ====>>tomcat01容器(提供服务),通过这个镜像可以创建多个容器(最终服务项目运行就在容器中)。

容器(container):

docker利用容器技术,独立运行一个或者一个组应用,通过镜像来创建的。 启动、停止、删除,基本命令! 目前可以把这个容器理解成一个简易的Linux系统。

仓库(repository):

仓库就是存放镜像的地方! 仓库分为共有仓库和私有仓库! docker hub(默认是国外的)

二、docker安装

注意:本文的命令使用的是 root 用户登录执行,不是 root 的话所有命令前面要加 sudo

环境准备

1.懂一点linux的基础

2.centos 7

环境查看

 

//使用uname -r命令查看系统内核,必须是3.10以上的
[root@localhost ~]# uname -r
3.10.0-1160.80.1.el7.x86_64
//系统版本
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

安装docker

//1.更新 yum 包(使用 root 权限,生产环境中此步操作需慎重)
//yum -y update 升级所有包同时也升级软件和系统内核;
//yum -y upgrade 只升级所有包,不升级软件和系统内核
yum -y update
//2.卸载旧的docker
yum remove docker  docker-common docker-selinux docker-engine
//3.安装软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
//4.设置 yum 源
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(默认是国外的)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)
//5.查看可用版本
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror
已安装的软件包
可安装的软件包
 * updates: mirrors.huaweicloud.com
Loading mirror speeds from cached hostfile
 * extras: mirrors.huaweicloud.com
docker-ce.x86_64            3:20.10.9-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.8-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.7-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.6-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.3-3.el7                    docker-ce-stable
//6.选择一个版本并安装
yum -y install docker-ce-18.03.1.ce
//7.启动 Docker
systemctl start docker
systemctl enable docker  设置开机自启
//8.使用docker version查看是否安装成功
[root@localhost ~]# docker version
Client:
 Version:           18.06.3-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        d7080c1
 Built:             Wed Feb 20 02:26:51 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.3-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       d7080c1
  Built:            Wed Feb 20 02:28:17 2019
  OS/Arch:          linux/amd64
  Experimental:     false
//至此,docker安装成功!!!

测试docker

//使用hello-world测试
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
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/
//查看刚才下载的hello-world镜像
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              feb5d9fea6a5        14 months ago       13.3kB
//至此,docker的安装测试全部完成!恭喜大家!

标签:centos,部署,ce,yum,Docker,com,docker
From: https://www.cnblogs.com/yzq-top/p/16923602.html

相关文章

  • Python3基于Centos7的安装
    0x00环境Centos7.9,默认已安装python2.7.50x01依赖软件yuminstallwgetzlib-develbzip2-developenssl-develncurses-develreadline-develtk-develgccmakezl......
  • Docker Java+Tomcat 环境搭建
    Docker更多资料请到​​https://dashboard.daocloud.io​​学习 软件环境:jdk、tomcat、docker、centos、虚拟机  首先,您要准备一个CentOS的操作系统,虚拟机也行。总之,......
  • JavaWeb+SVN+Maven+Tomcat +jenkins实现自动化部署
       在日常开发项目中常见的开发模式是使用代码库来存放我们的项目例如:SVN、Git、CVS等,采用Maven来进行项目管理而需要在测试和发布项目的时候需要手动打包然后部署到服......
  • Vue项目打包后部署到express服务器
    背景有的时候我们在使用vue脚手架开发完项目后想在本地的服务器上运行进行调试,因为有的时候开发时和打包后的效果有些许差异。步骤安装expressnpminstallexpress-sa......
  • eck 部署2.0 版本
    一.ECK部署2.0官网kubectlcreate-fhttps://download.elastic.co/downloads/eck/2.0.0/crds.yamlkubectlapply-fhttps://download.elastic.co/downloads/eck/2.0.......
  • centos7简单登录redis
    登录数据库:redis_cli-h[host]-p[port]输入用户名、密码登录auth[username]password选择数据库selectindex12.1对key操作的命令keys*:查询所有的ke......
  • DevOps持续部署的关键要素
     当有版本通过持续集成流水线进行构建之后,就可以将其部署至某个具体的环境,这就需要自动化部署技术,将这个自动化部署和持续集成流水线连接起来,就可实现持续部署。如图1所......
  • 一文说清楚Dockerfile 中VOLUME到底有什么用?
    一文说清楚Dockerfile中VOLUME到底有什么用?原创2021-10-2500:25:2125点赞https://blog.csdn.net/qq32933432/article/details/120944205诺浅码龄11年关注写在开头相......
  • linux docker 远程连接配置
    新买的服务器安装docker,记录下配置过程默认配置下,dockerdaemon只响应来自本地host的客户端请求。如果需要远程客户端请求,需要修改配置文件vim/etc/systemd/system/mu......
  • pve开启lxc容器ipv6并为docker-qBittorrent容器配置ipv6
    pve开启lxc容器ipv6并为docker容器配置ipv6写这篇文档是记录一下为了记录用pveLXC容器安装的docker版qBittorrent开启ipv6,这样下载的速度会快一点,这其中有很多坑,随笔记录......