提前下载一些工具:
文件上传工具:yum install -y lrzsz
1.搭建docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
配置镜像
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://wxsi86xv.mirror.aliyuncs.com"]
}
EOF
刷新 sudo systemctl daemon-reload
重启 sudo systemctl restart docker
2.docker安装nginx
docker search nginx
docker pull nginx(具体可以看看喜欢哪个版本)
先创建宿主机的文件
mkdir -p /etc/nginx/conf/
mkdir -p /etc/nginx/html/
mkdir -p /etc/nginx/logs
拷贝:
docker cp nginx:/etc/nginx /etc/nginx/conf/ # 这里估计是多了/导致多了conf/nginx
docker cp nginx:/usr/share/nginx/html/index.html /etc/nginx/html/index.html
docker cp nginx:/var/log/nginx /etc/nginx/logs
启动容器:
docker run --name nginx -d -p 80:80 -p 443:443 -v /etc/nginx/html:/usr/share/nginx/html -v /etc/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /etc/nginx/logs:/var/log/nginx nginx
(这里也有个问题,要把改成/etc/nginx/conf:/etc/nginx )
提前下载需要的镜像
3.docker 安装 sentinel
docker run --restart always --name sentinel -d -p 8858:8858 -d bladex/sentinel-dashboard:latest
4.docker 安装rocket server、broker、console
docker run -d -p 9876:9876 --name rmqserver foxiswho/rocketmq:server-4.5.1
docker run -d -p 10911:10911 -p 10909:10909 --name rmqbroker --link rmqserver:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt" -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m" -v /usr/local/rocketmq/broker.conf:/etc/rocketmq/broker.conf foxiswho/rocketmq:broker-4.5.1
docker run -d --name rmqconsole -p 8092:8080 --link rmqserver:namesrv -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -t styletang/rocketmq-console-ng
5.docker 安装nacos
docker run --name nacos -d -p 8848:8848 --privileged=true --restart=always -e JVM_XMS=256m -e JVM_XMX=256m -e MODE=standalone -e PREFER_HOST_MODE=hostname nacos/nacos-server:latest
注意:如果nginx需要代理哪些端口需要开起来,例如8848
docker run --name nginx -d -p 80:80 -p 443:443 -p 8848:8848 -v /etc/nginx/html:/usr/share/nginx/html -v /etc/nginx/conf:/etc/nginx -v /etc/nginx/logs:/var/log/nginx nginx