使用docker-compose安装mysql和redis的详细步骤
时间: 2024-02-24 09:38:04 浏览: 231
docker-compose启动mysql、redis服务
Sure! Here are the steps to install MySQL and Redis using docker-compose:
1. Create a new directory for your project and navigate into it.
2. Create a file called docker-compose.yml in this directory and add the following code:
version: '3'
services:
db:
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: your_mysql_root_password
ports:
- "3306:3306"
redis:
image: redis:latest
restart: always
ports:
- "6379:6379"
3. Replace "your_mysql_root_password" with a strong password of your choice.
4. Save the file and exit.
5. Run the command "docker-compose up -d" to start the containers in detached mode.
6. You can now connect to MySQL using your preferred MySQL client and the following parameters:
Host: localhost
Port: 3306
User: root
Password: your_mysql_root_password
7. You can also connect to Redis using the following parameters:
Host: localhost
Port: 6379
I hope this helps! Let me know if you have any further questions.
阅读全文