1.先换源
vi /etc/apt/sources.list
更新成下面的源地址
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
2.更新源
apt-get update
3.查询RabbitMQ镜像
docker search rabbitmq
3.拉取RabbitMQ镜像
docker pull rabbitmq #(镜像未配有控制台)
docker pull rabbitmq:management #(镜像配有控制台)
#注意:rabbitmq是官方镜像,该镜像不带控制台。如果要安装带控制台的镜像,需要在拉取镜像时附带tag标签,例如:management。tag标签可以通过https://hub.docker.com/_/rabbitmq?tab=tags来查询。
#执行
docker pull rabbitmq:management
4.安装RabbitMQ
docker run --name rabbitmq -d -p 15672:15672 -p 5672:5672 rabbitmq:management
常规操作
#启动 RabbitMQ 容器
docker start rabbitmq
#停止 RabbitMQ 容器
docker stop rabbitmq
#重启 RabbitMQ 容器
docker restart rabbitmq
#查看 RabbitMQ 容器进程信息
docker top rabbitmq
#控制台信息
#启动容器后,可以浏览器中访问http://localhost:15672来查看控制台信息。
#RabbitMQ默认的用户名:guest,密码:guest
问题及解决
#docker stop [CONTAINER ID] 失败,导致 docker rm [CONTAINER ID] 失败
docker rm -f [CONTAINER ID] //强制删除
#再次创建容器但是报错,网络节点被占用
#docker: Error response from daemon: endpoint with name rabbitmq already exists in network bridge.
ps -ef | grep rabbitmq
docker network disconnect --force bridge [rabbitmq 节点名称]