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的版本


前置条件

在这里插入图片描述
在这里插入图片描述

[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

在这里插入图片描述

#  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仓库,这里调过操作

在这里插入图片描述


Step3. INSTALL DOCKER CE

在这里插入图片描述

在这里插入图片描述

这里我们选择第二种方式,来安装特定版本的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

在这里插入图片描述

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
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付 9.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值