由于您的需求是部署常见的中间件服务,并且您已经提到这些服务在Docker上的部署是“亲测成功”的,我将给出一些常见的Docker部署中间件的示例。
- Redis:
FROM redis:latest
- RabbitMQ:
FROM rabbitmq:3-management
- MySQL 8:
FROM mysql:8.0
ENV MYSQL_DATABASE=your_database_name
ENV MYSQL_USER=your_user
ENV MYSQL_PASSWORD=your_password
ENV MYSQL_ROOT_PASSWORD=your_root_password
COPY ./custom-script.sql /docker-entrypoint-initdb.d/
- Elasticsearch:
FROM docker.elastic.co/elasticsearch/elasticsearch:7.10.0
- Kibana:
FROM kibana:7.10.0
ENV ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- Nginx:
FROM nginx:latest
COPY ./nginx.conf /etc/nginx/nginx.conf
请注意,这些Dockerfile仅仅展示了基本的部署指令。您可能需要根据您的具体需求进行配置调整,例如环境变量、卷挂载、网络设置等。
在实际部署时,您可以使用docker-compose
来简化管理多个容器的过程。以下是一个docker-compose.yml
的示例:
version: '3'
services:
redis:
image: redis:latest
ports:
- "6379:6379"
rabbitmq:
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672"
mysql:
image: mysql:8.0
environment:
MYSQL_DATABASE: your_database_name
MYSQL_USER: your_user
MYSQL_PASSWORD: your_password
MYSQL_ROOT_PASSWORD: your_root_password
volumes:
- your_local_mysql_data_folder:/var/lib/mysql
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
environment:
- discovery.type=single-node
volumes:
- your_local_elasticsearch_data_folder:/usr/share/elasticsearch/data
kibana:
image: kibana:7.10.0
environment:
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
depends_on:
- elasticsearch
nginx:
image: nginx:latest
volumes:
- your_local_nginx_conf_folder:/etc/nginx/conf.d
ports:
- "80:80"
volumes:
your_local_mysql_data_folder:
your_local_elasticsearch_data_folder:
your_local_nginx_conf_folder:
请确保替换掉以上配置中的your_
开头的变量,并根据实际情况调整卷挂载路径和端口映射。
在配置文件准备好后,使用以下命令启动所有服务:
docker-compose up -d
以上是一个基本的示例,您可以根据自己的需求进行定制化配置。