我正在使用docker-compose来创建一个使用PHP和MySQL的Web应用程序。运行MySQL的容器安装了数据库,但是我无法在那里找到该表。我已经使用了包含表.sql扩展名的卷。
下面是我的docker-compose.yml文件
`version: '3'
services:
web_1:
container_name: web1_2
build: .
ports:
- "8081:80"
networks:
test:
ipv4_address: 172.28.0.2
web_2:
container_name: web2_2
build: .
ports:
- "8082:80"
networks:
test:
ipv4_address: 172.28.0.3
lb_2:
container_name: lb_2
build: ./lb
ports:
- "8080:80"
networks:
test:
ipv4_address: 172.28.0.4
db_2:
container_name: db_2
image: mysql:latest
restart: always
volumes:
- dbdata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: cloud
MYSQL_USER: root
MYSQL_PASSWORD: password
ports:
- "3306:3306"
networks:
test:
ipv4_address: 172.28.0.5
networks:
test:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
volumes:
dbdata:
`
这是我在mmantig上的hostmachine上的sql文件 docker容器上的/ var / lib / sql。
`CREATE TABLE cloud.basic (name VARCHAR(20), age INT, location VARCHAR(20));
INSERT INTO TABLE cloud.basic VALUES ("Sampy", 23, "Boulder");
INSERT INTO TABLE cloud.basic VALUES ("Gian", 27, "Raton");`
你认为我哪里错了?我的方法有误吗?任何帮助将不胜感激