英文:
incorrect database displayed in docker container
问题
我的数据库被定义为blue
,但是当我在终端中查找时,显示为red
。我之前启动了一个定义为red
的数据库容器,但是已经删除并完全移除了它。我尝试过使用--build
标志重新启动容器,但没有成功。发生了什么事?
英文:
My database is defined as blue
:-
docker-compose.yaml
version: '3'
services:
#PHP Service
ngxapp:
build:
context: .
dockerfile: Dockerfile
image: andys
container_name: ngxapp
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: ngxapp
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
ngxwebserver:
image: nginx:alpine
container_name: ngxwebserver
restart: unless-stopped
tty: true
ports:
- "8097:80"
- "4431:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#MySQL Service
ngxdb:
image: mysql:5.7.22
container_name: ngxdb
restart: unless-stopped
tty: true
ports:
- "3418:3306"
environment:
MYSQL_USER: root
MYSQL_DATABASE: blue
MYSQL_ROOT_PASSWORD: password
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
seen here;-
however, when i go to the terminal and look for it there, it's displaying as red
:-
what's happening? I have span up another container with a db defined as red
previously, but have since deleted and removed it entirely.
I've tried restarting the container with the --build
flag also, no success.
答案1
得分: 0
你应该重置你的 dbdata
数据库 Docker volume:
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
尝试:
docker volume rm dbdata
这将删除所有的 MySQL 数据。下次你运行 docker-compose up
时,MySQL 将从头开始初始化,blue
数据库应该会被创建。
英文:
You should probably reset your dbdata
DB Docker volume:
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
Try:
docker volume rm dbdata
This will erase all MySQL data. Next time you do docker-compose up
MySQL will be initialized from scratch and blue
DB should be created.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论