Docker从搭建到部署微服务,一路走来,命令合集(7)
2018-05-07 本文已影响113人
ROCK_杰哥
docker部署为服务很麻烦,从一个纯净的虚拟机,依次运行一下命令,一把梭····
可以整理一个脚本就不用这么麻烦了
#安装docker
1,yum update -y
2,yum -y install docker
3,systemctl start docker
4,systemctl enable docker
#安装docker-compose
5,yum -y install epel-release
6,yum -y install python-pip
7,pip install --upgrade pip
8,pip install docker-compose
9,docker-compose
10,docker-compose version
#配置docker可远程调用
vi /etc/sysconfig/docker-network
#修改下面这句话
DOCKER_NETWORK_OPTIONS="-H unix:///var/run/docker.sock -H 0.0.0.0:2375"
#重启
systemctl daemon-reload
systemctl restart docker
#配置windows环境变量
新建DOCKER_HOST,值为tcp://192.168.131.142:2375
#为了本地上传镜像的时候不受端口的影响,关闭防火墙,开机不启动(测试)
systemctl stop firewalld.service
systemctl disable firewalld.service
#在本地项目的根目录下执行
mvn clean package docker:build -DskipTests
#由于docker在国外,时长会断,修改
vi /etc/docker/daemon.json
#加上
{"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]}
#接下来执行编写好docker-compose.yml,传至服务器,在这个文件所在的文件夹运行
docker-compose up -d
#启动完之后,就已经起来了,
http://192.168.131.142:8761/
http://192.168.131.141:8083/
http://192.168.131.141:8989/



代码地址:https://github.com/11078334334/ch12.git
查看已经开放的端口:
firewall-cmd --list-ports
开启端口
firewall-cmd --zone=public --add-port=2375/tcp --permanent
重启
systemctl restart firewalld