运行容器
Nginx
docker run -d \
-p 81:80 \
--name nginx81 \
-v /usr/local/nginx/html/hm-mall-portal:/usr/share/nginx/html \
-v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
nginx
version: '3.7'
services:
nginx:
image: nginx
container_name: nginx
restart: always
volumes:
- /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- /usr/local/nginx/html:/usr/share/nginx/html
ports:
- 80:80
MySQL
docker run -d \
--name mysql3306 \
-p 3306:3306 \
-v /tmp/mysql/conf/hmy.cnf:/etc/mysql/conf.d/hmy.cnf \
-v /tmp/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=root\
mysql:5.7.25
version: '3.7'
services:
mysql:
image: mysql:5.7.25
container_name: mysql3306
restart: always
volumes:
- /tmp/mysql/conf/hmy.cnf:/etc/mysql/conf.d/hmy.cnf
- /tmp/mysql/data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
Tomcat
docker run -d \
-p 8080:8080 \
--name tomcat \
-v $pwd/webapps:/usr/local/tomcat/webapps \
-e TZ:Asia/Shanghai \
tomcat
version: '3.7'
services:
tomcat:
image: tomcat
container_name: tomcat
restart: always
ports:
- 8080:8080
volumes:
- ./webapps:/usr/local/tomcat/webapps
environment:
TZ: Asia/Shanghai
Redis
docker run -d \
--name redis \
-p 6379:6379 \
-v /usr/local/redis-6.2.4:/usr/local/etc/redis \
redis
version: '3.7'
services:
redis:
image: redis
container_name: redis
restart: always
volumes:
- /usr/local/redis-6.2.4:/usr/local/etc/redis
ports:
- 6379:6379
Nacos
docker run -d \
--name nacos \
-p 8848:8848 \
-e MODE=standalone \
nacos/nacos-server
version: '3.7'
services:
nacos:
image: nacos/nacos-server
container_name: nacos
environment:
MODE: standalone
ports:
- 8848:8848
RabbitMQ
docker run \
-e RABBITMQ_DEFAULT_USER=itcast \
-e RABBITMQ_DEFAULT_PASS=123321 \
-v mq-plugins:/plugins \
--name mq \
--hostname mq \
--restart=always \
-p 15672:15672 \
-p 5672:5672 \
-d \
rabbitmq:3-management
version: '3.7'
services:
rabbitmq:
image: rabbitmq:3-management
RABBITMQ_DEFAULT_USER: itcast
RABBITMQ_DEFAULT_PASS: 123321
mq-plugins: /plugins
container_name: mq
hostname: mq
ports:
- 15672:15672
- 5672:5672
restart: always
volumes:
- ./data:/var/lib/rabbitmq
Elasticsearch
docker network create es-net
docker run -d \
--name es \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-e "discovery.type=single-node" \
-v es-data:/usr/share/elasticsearch/data \
-v es-plugins:/usr/share/elasticsearch/plugins \
--privileged \
--network es-net \
-p 9200:9200 \
-p 9300:9300 \
elasticsearch:7.12.1
version: '3.7'
services:
elasticsearch:
image: elasticsearch:7.12.1
container_name: elasticsearch
privileged: true
environment:
- "cluster.name=elasticsearch" #设置集群名称为elasticsearch
- "discovery.type=single-node" #以单一节点模式启动
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" #设置使用JVM内存大小
volumes:
- ./es-plugins:/usr/share/elasticsearch/plugins #插件文件挂载
- ./es-data:/usr/share/elasticsearch/data #数据文件挂载
ports:
- 9200:9200
- 9300:9300
networks:
- es-net
networks:
es-net:
driver: bridge
Kibana
docker run -d \
--name kibana \
-e ELASTICSEARCH_HOSTS=http://es:9200 \
--network=es-net \
-p 5601:5601 \
kibana:7.12.1
version: '3.7'
services:
kibana:
image: kibana:7.12.1 #与elasticsearch的版本必须一致
container_name: kibana
networks:
- es-net
environment:
ELASTICSEARCH_HOSTS: http://es:9200 #设置访问elasticsearch的地址
I18N_LOCALE: zh-CN
ports:
- 5601:5601
networks:
es-net:
driver: bridge
标签:name,--,nginx,elasticsearch,usr,Docker,lxl,es From: https://www.cnblogs.com/linxiaofeng/p/16724214.html