Docker-Centos7安装Docker CE 及在Docker CE中安装RabbitMQ

简介: Docker-Centos7安装Docker CE 及在Docker CE中安装RabbitMQ

Docker版本说明


参考官网: https://docs.docker.com/release-notes/docker-engine/


主要意思是 Docker Engine 的版本号范围: 0.1.0 ~ 1.13.1。 新的版本变更为 Docker CE or Docker EE.


在 2017 年 3 月 2 日, docker 团队宣布


企业版 Docker Enterprise Edition ( EE ) 发布.

免费的 Docker Engine 改名为 Docker Community Edition ( CE )

并且采用基于时间的版本号方案.


Docker EE 和 Docker CE 第一个采用新的版本号方案的版本为17.03 。


Docker CE 的两个版本


Stable 每个季度提供可靠更新

Edge 每个月提供新功能


Docker安装


官方指导文档: https://docs.docker.com/install/linux/docker-ce/centos/

我这里要是装的是 17.12的版本


前置条件



20190403000155481.png


20190403000210275.png

[root@artisan ~]# yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker-client-latest
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos will be erased
---> Package docker-client.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos will be erased
---> Package docker-common.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
 Package           Arch       Version                                Repository   Size
=======================================================================================
Removing:
 docker            x86_64     2:1.13.1-94.gitb2f74b2.el7.centos      @extras      65 M
 docker-client     x86_64     2:1.13.1-94.gitb2f74b2.el7.centos      @extras      13 M
 docker-common     x86_64     2:1.13.1-94.gitb2f74b2.el7.centos      @extras     4.4 k
Transaction Summary
=======================================================================================
Remove  3 Packages
Installed size: 77 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64                     1/3 
warning: /etc/sysconfig/docker-storage saved as /etc/sysconfig/docker-storage.rpmsave
  Erasing    : 2:docker-client-1.13.1-94.gitb2f74b2.el7.centos.x86_64              2/3 
  Erasing    : 2:docker-common-1.13.1-94.gitb2f74b2.el7.centos.x86_64              3/3 
  Verifying  : 2:docker-common-1.13.1-94.gitb2f74b2.el7.centos.x86_64              1/3 
  Verifying  : 2:docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64                     2/3 
  Verifying  : 2:docker-client-1.13.1-94.gitb2f74b2.el7.centos.x86_64              3/3 
Removed:
  docker.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos                                      
  docker-client.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos                               
  docker-common.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos                               
Complete!


Step1. Set up the Repository


20190402234955317.png

#  install必要的包
[root@artisan ~]#  yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyuncs.com
 * extras: mirrors.aliyuncs.com
 * updates: mirrors.aliyuncs.com
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version
Package 7:lvm2-2.02.180-10.el7_6.3.x86_64 already installed and latest version
Nothing to do
#  设置stable 的仓库 
[root@artisan ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo


Step2. Enable the nightly or test repositories(Optional)

可以选择是否开启edge和test仓库,这里调过操作


20190402235102161.png

Step3. INSTALL DOCKER CE



20190402235308830.png


20190402235333401.png



这里我们选择第二种方式,来安装特定版本的docker ce

# 查看所有仓库中所有docker版本
[root@artisan ~]# yum list docker-ce --showduplicates | sort -r
 * updates: mirrors.aliyuncs.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
 * extras: mirrors.aliyuncs.com
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
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.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
 * base: mirrors.aliyuncs.com
Available Packages
[root@artisan ~]# 
# 由于repo中默认只开启stable仓库,这里安装的是最新稳定版 (未执行,只是记录下)
[root@artisan ~]# yum install docker-ce  
# 选择特定版本安装
[root@artisan ~]# yum install docker-ce-17.12.1.ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyuncs.com
 * extras: mirrors.aliyuncs.com
 * updates: mirrors.aliyuncs.com
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.12.1.ce-1.el7.centos will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-17.12.1.ce-1.el7.centos.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.74-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
 Package              Arch      Version                      Repository           Size
=======================================================================================
Installing:
 docker-ce            x86_64    17.12.1.ce-1.el7.centos      docker-ce-stable     30 M
Installing for dependencies:
 container-selinux    noarch    2:2.74-1.el7                 extras               38 k
Transaction Summary
=======================================================================================
Install  1 Package (+1 Dependent package)
Total size: 30 M
Total download size: 30 M
Installed size: 30 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for docker-ce-stable
docker-ce-17.12.1.ce-1.el7.cen FAILED                                          :19 ETA 
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm: [Errno 12] Timeout on https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm is not installed
docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm                    |  30 MB  00:14:48     
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:container-selinux-2.74-1.el7.noarch                               1/2 
  Installing : docker-ce-17.12.1.ce-1.el7.centos.x86_64                            2/2 
  Verifying  : 2:container-selinux-2.74-1.el7.noarch                               1/2 
  Verifying  : docker-ce-17.12.1.ce-1.el7.centos.x86_64                            2/2 
Installed:
  docker-ce.x86_64 0:17.12.1.ce-1.el7.centos                                           
Dependency Installed:
  container-selinux.noarch 2:2.74-1.el7                                                
Complete!
# 查看docker ce的版本 
[root@artisan ~]# docker version
Client:
 Version: 17.12.1-ce
 API version: 1.35
 Go version:  go1.9.4
 Git commit:  7390fc6
 Built: Tue Feb 27 22:15:20 2018
 OS/Arch: linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@artisan ~]# 


Step4. Start Docker

# 启动Docker
[root@artisan ~]# systemctl start docker
# 开机启动
[root@artisan ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.


Step5. Verify that Docker CE


运行hello-world镜像来测试是否安装成功,本地没有镜像时会自动从docker hub中下载,当出现Hello from Docker!即表示安装成功


[root@artisan ~]# docker run hello-world 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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/
[root@artisan ~]# 
# 列出本地镜像
[root@artisan ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        3 months ago        1.84kB
# 列出所有的容器
[root@artisan ~]# docker ps -all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
7d94df25027f        hello-world         "/hello"            30 minutes ago      Exited (0) 30 minutes ago                       cocky_hoover
[root@artisan ~]# 


Docker CE中安装RabbitMQ


Docke镜像官方下载地址: https://www.rabbitmq.com/download.html#docker

我们这里使用rabbitmq:3.7.8-management (management为带管理界面的版本)

# 安装启动rabbitmq
#  第一个-p是rabbitmq运行所占用的端口号,第二个是rabbitmq启动成功后,对外暴露的端口,即可访问的端口号
[root@artisan ~]# docker run -d --hostname my-rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.7.8-management
Unable to find image 'rabbitmq:3.7.8-management' locally
3.7.8-management: Pulling from library/rabbitmq
f17d81b4b692: Pull complete 
02fe1bd1a85c: Pull complete 
66c15a50f4da: Pull complete 
771c4c62018c: Pull complete 
05e166e2684c: Pull complete 
5eb4efce3466: Pull complete 
9b5d77af0f63: Pull complete 
f7fc14f8eeeb: Pull complete 
31e1448101d9: Pull complete 
196612f40314: Pull complete 
8cd7ab5c5659: Pull complete 
aae6dd0bf4aa: Pull complete 
c8f2ac2cd4e8: Pull complete 
98e5c73758c4: Pull complete 
Digest: sha256:3eb2fa0f83914999846f831f14b900c0c85cea8e5d2db48ff73cf7defa12fe96
Status: Downloaded newer image for rabbitmq:3.7.8-management
2fd1eec6704207bcb7d67f3f81cc1d8ba63e889eb72007d07e28cd73c7dbb28d
[root@artisan ~]# 
# 列出容器
[root@artisan ~]# docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED              STATUS              PORTS                                                                                        NAMES
2fd1eec67042        rabbitmq:3.7.8-management   "docker-entrypoint.s…"   About a minute ago   Up About a minute   4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp   cocky_mccarthy
[root@artisan ~]# 


访问 http://192.168.31.34:15672/ 默认用户名和密码为 guest



20190403002914623.png


RabbitMQ默认账户密码为guest/guest,如果不想使用默认密码,可在启动容器时设置-e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password ,换成想要的用户名和密码即可。

docker run -d --hostname my-rabbitmq -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password  rabbitmq:3.7.8-management


相关实践学习
快速体验阿里云云消息队列RocketMQ版
本实验将带您快速体验使用云消息队列RocketMQ版Serverless系列实例进行获取接入点、创建Topic、创建订阅组、收发消息、查看消息轨迹和仪表盘。
消息队列 MNS 入门课程
1、消息队列MNS简介 本节课介绍消息队列的MNS的基础概念 2、消息队列MNS特性 本节课介绍消息队列的MNS的主要特性 3、MNS的最佳实践及场景应用 本节课介绍消息队列的MNS的最佳实践及场景应用案例 4、手把手系列:消息队列MNS实操讲 本节课介绍消息队列的MNS的实际操作演示 5、动手实验:基于MNS,0基础轻松构建 Web Client 本节课带您一起基于MNS,0基础轻松构建 Web Client
相关文章
|
3月前
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
767 69
|
2月前
|
存储 分布式计算 Linux
安装篇--CentOS 7 虚拟机安装
VMware 装 CentOS 7 不知道从哪下手?这篇超详细图文教程手把手教你在 VMware Workstation 中完成 CentOS 7 桌面系统的完整安装流程。从 ISO 镜像下载、虚拟机配置,到安装图形界面、设置用户密码,每一步都有截图讲解,适合零基础新手快速上手。装好之后无论你是要搭 Hadoop 集群,还是练 Linux ,这个环境都够你折腾一整天!
1070 2
|
3月前
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
386 78
|
2月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
567 16
|
4月前
|
Linux 网络安全 Apache
针对在Centos/Linux安装Apache过程中出现的常见问题集锦
以上每个问题的解决方案应深入分析错误日志、系统消息和各种配置文件,以找到根本原因并加以解决。务必保持系统和Apache软件包更新到最新版本,以修复已知的bugs和安全漏洞。安装和管理Web服务器是一项需要细致关注和不断学习的任务。随着技术的发展,推荐定期查看官方文档和社区论坛,以保持知识的更新。
238 80
|
3月前
|
存储 关系型数据库 MySQL
在CentOS 8.x上安装Percona Xtrabackup工具备份MySQL数据步骤。
以上就是在CentOS8.x上通过Perconaxtabbackup工具对Mysql进行高效率、高可靠性、无锁定影响地实现在线快速全量及增加式数据库资料保存与恢复流程。通过以上流程可以有效地将Mysql相关资料按需求完成定期或不定期地保存与灾难恢复需求。
330 10
|
4月前
|
人工智能 数据挖掘 Linux
Centos安装Python3.7(亲测可用)
本指南详细介绍了在基于Linux(以CentOS系统为例,使用yum包管理器)的系统上安装Python 3.7版本的完整流程。Python是一种广泛使用的高级编程语言,在各种领域如软件开发、数据分析、人工智能和区块链开发等都有着重要的应用。
484 4
|
5月前
|
机器人 Linux
CentOS 7系统中安装特定版本CMake 3.21.2的方法。
到这里,过程已经全部完成。如果你跟随上面的步骤来,那么你现在已经拥有了一个全新的CMake版本在你的CentOS 7系统上了。这个过程就像是你通过一系列仪式,唤醒了一个沉睡已久的古老机器人,它现在完全按照你的意愿来帮你构建和编译软件了。
498 18
|
3月前
|
运维 网络协议 Linux
CentOS下Bind服务的安装与故障排查
通过以上的步骤,您应该能够在CentOS系统上安装并配置BIND DNS服务,并进行基本的故障排查。
370 0
|
5月前
|
消息中间件 监控 Docker
Docker环境下快速部署RabbitMQ教程。
就这样,你成功地用魔法召唤出了RabbitMQ,还把它和你的应用程序连接了起来。现在,消息会像小溪流水一样,在你的系统中自由流淌。别忘了,兔子们不喜欢孤独,他们需要你细心的关怀,不时地监控它们,确保他们的世界运转得井井有条。
343 18