#1,数据源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#2, 更新yum软件包索引
yum makecache fast
3,安装docker ce
yum -y install docker-ce
#报错 Problem: package docker-ce-3:20.10.0-3.el7.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
#强制安装1.4.3-3.1版本的包
dnf install https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.4.3-3.1.el8.x86_64.rpm
#安装1.4.3-3.1包 遇到以下报错的话
#Error:
#Problem: problem with installed package podman-2.2.1-7.module_el8.3.0+699+d61d9c41.x86_64
yum erase podman buildah
y
yum -y install docker-ce
#开机自启
systemctl enable docker.service
#启动
systemctl start docker.service
#docker 安装nginx
docker pull nginx:1.10
随便启动一个nginx实例,只是为了复制出配置,放到docker里作为镜像的统一配置
docker run -p 80:80 --name nginx -d nginx:1.10
cd /mydata/nginx
注意这个点
docker container cp nginx:/etc/nginx .
#然后在外部 /mydata/nginx/nginx 有了一堆文件
mv /mydata/nginx/nginx /mydata/nginx/conf
停掉nginx
docker stop nginx
docker rm nginx
创建新的nginx
docker run -p 80:80 --name nginx
-v /mydata/nginx/html:/usr/share/nginx/html
-v /mydata/nginx/logs:/var/log/nginx
-v /mydata/nginx/conf:/etc/nginx
-d nginx:1.10
注意一下这个路径映射到了/usr/share/nginx/html,我们在nginx配置文件中是写/usr/share/nginx/html,不是写/mydata/nginx/html
docker update nginx --restart=always
拉取镜像
docker pull nacos/nacos-server
挂载目录
mkdir -p /mydata/nacos/logs/ #新建logs目录
mkdir -p /mydata/nacos/init.d/
vim /mydata/nacos/init.d/custom.properties #修改配置文件
mysql新建nacos的数据库,并执行脚本
链接: link
修改配置文件
server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://xx.xx.xx.x:3306/ [your_database] ?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user= [your_user]
db.password= [your_pass]
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t “%r” %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,//*.css,//.js,/**/.html,//*.map,//.svg,/**/.png,//*.ico,/console-fe/public/,/v1/auth/login,/v1/console/health/,/v1/cs/,/v1/ns/,/v1/cmdb/,/actuator/,/v1/console/server/
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true
#启动容器
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
-v /mydata/nacos/logs:/home/nacos/logs
-v /mydata/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties
nacos/nacos-server