1:安装docker
在mac 上安装docker
参考:https://docs.docker.com/docker-for-mac/install/
在windows上安装docker
参考: https://docs.docker.com/docker-for-windows/install/
在centos 上安装docker
- 新建安装脚本
vim docker.sh
chmod +x docker.sh
# bin/bash
rm -rf /usr/local/bin/docker-compose
sudo yum remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce.x86_64 0:18.03.1.ce-1.el7.centos
curl -L https://get.daocloud.io/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker 加速
- 由于国内网络原因,DOCKER访问docker hub经常超时,为了能够给DOCKER加速,我们可使用国内DOCKER镜像:
登陆阿里云申请自己的加速器:
https://cr.console.aliyun.com/
image.png
vim /etc/docker/daemon.json
{
"registry-mirrors": [ "https://********.com"]
}
- 重启docker
systemctl daemon-reload
systemctl restart docker
- 执行systemctl restart docker出错:
Failed to start docker.service: Unit not found.
https://www.cnblogs.com/ggsmida/p/6738539.html
2:开始使用
检查版本
执行以下命令检查docker,docker-compose,docker-machine版本。
fangledeMacBook-Pro:~ fangle$ docker --version
Docker version 17.12.0-ce, build c97c6d6
fangledeMacBook-Pro:~ fangle$ docker-compose --version
docker-compose version 1.18.0, build 8dd22a9
fangledeMacBook-Pro:~ fangle$ docker-machine --version
docker-machine version 0.13.0, build 9ba6da9
fangledeMacBook-Pro:~ fangle$
- 我安装完成后,执行docker-machine --version失败了,所以单独安装了一下docker-machine
curl -L https://github.com/docker/machine/releases/download/v0.13.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
安装RabbitMQ
[root@iZwz9esy3n96et8lt7s6m9Z ~]# docker search rabbitmq
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
rabbitmq RabbitMQ is an open source multi-protocol me… 2024 [OK]
tutum/rabbitmq Base docker image to run a RabbitMQ server 17
frodenas/rabbitmq A Docker Image for RabbitMQ 12 [OK]
bitnami/rabbitmq Bitnami Docker Image for RabbitMQ 10 [OK]
kbudde/rabbitmq-exporter rabbitmq_exporter for prometheus 6 [OK]
sysrun/rpi-rabbitmq RabbitMQ Container for the Raspberry Pi 2 (b… 6
gonkulatorlabs/rabbitmq DEPRECATED: See maryville/rabbitmq 5 [OK]
arm32v7/rabbitmq RabbitMQ is an open source multi-protocol me… 5
cyrilix/rabbitmq-mqtt RabbitMQ MQTT Adapter 4 [OK]
aweber/rabbitmq-autocluster RabbitMQ with the Autocluster Plugin 4
mikaelhg/docker-rabbitmq RabbitMQ in Docker. 3 [OK]
gavinmroy/alpine-rabbitmq-autocluster Minimal RabbitMQ image with the autocluster … 2
pivotalrabbitmq/rabbitmq-autocluster RabbitMQ with the rabbitmq-autocluster plugi… 2
luiscoms/openshift-rabbitmq RabbitMQ docker image to use on Openshift ba… 2 [OK]
authentise/rabbitmq A RabbitMQ image that will run a bash script… 2 [OK]
cvtjnii/rabbitmq 1
henrylv206/rabbitmq-autocluster RabbitMQ Cluster 1 [OK]
nasqueron/rabbitmqadmin RabbitMQ management plugin CLI tool Lightwei… 1 [OK]
pivotalrabbitmq/rabbitmq-server-buildenv Image used to build and test RabbitMQ server… 1
pdffiller/rabbitmq Rabbitmq 3.7.3 with delayed_message plugin,c… 0
newsdev/rabbitmq rabbitmq:olympics Extends official rabbitmq … 0 [OK]
ekesken/rabbitmq docker image for rabbitmq that is configurab… 0 [OK]
hoist/rabbitmq-cluster Hoist's RabbitMQ Cluster Image 0 [OK]
vituity/openshift-rabbitmq RabbitMQ for OpenShift 0 [OK]
- 选择安装官方的镜像
[root@iZwz9esy3n96et8lt7s6m9Z ~]# docker pull rabbitmq
- 启动RabbitMQ
docker run -d --name myrabbitmq -p 5672:5672 -p 15672:15672 docker.io/rabbitmq:3-management
-
这里选择映射容器的15672端口到centos的15673端口,所以直接访问服务器的15672端口,这一步非必须。
-
RabbitMQ默认账户密码为guest/guest,如果不想使用默认密码,则在启动容器时可以设置,在下面命令的user和password替换就ok。
docker run -d --hostname my-rabbit --name some-rabbit -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management
- 更多启动参数请参考官方文档
https://hub.docker.com/_/rabbitmq/
image.png- 容器的停止与删除
docker stop
docker rm
更多常用的docker命令
https://springframework.guru/docker-cheat-sheet-for-spring-devlopers/
网友评论