我搞不懂这个。下面是我的docker文件。这是一个docker swarm,但都在一台主机上(只是测试设置)。我正在尝试向mysql添加一个应用程序用户,以便web容器可以访问db容器的mysql服务器。我不想使用通用主机通配符,因为db容器的mysql端口将向世界开放。有没有办法自动完成?我已尝试对主机使用“web”,但总是因为“10.0.0.x”错误而拒绝访问。
谢谢!
更新sql:
UPDATE mysql.user SET host = 'web' where user = 'app';
FLUSH PRIVILEGES;
连接错误:
Access denied for user 'app'@'10.0.1.4' (using password: YES)
docker撰写:
version: "3.4"
services:
web:
image: app:latest
ports:
- 4000:80
# networks:
# - appnet
volumes:
- uploads:/app/uploads
secrets:
- dbapp
- mailkey
- sessionsecret
deploy:
replicas: 1
restart_policy:
condition: on-failure
delay: 1s
max_attempts: 10
redis:
image: redis:alpine
# networks:
# - appnet
db:
image: mysql:5.7
# networks:
# - appnet
secrets:
- dbroot
- dbapp
environment:
MYSQL_DATABASE: "app"
MYSQL_USER: "app"
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/dbroot
MYSQL_PASSWORD_FILE: /run/secrets/dbapp
volumes:
- db:/var/lib/mysql
- ./scripts:/docker-entrypoint-initdb.d
secrets:
dbroot:
external: true
dbapp:
external: true
sessionsecret:
external: true
mailkey:
external: true
volumes:
uploads:
db:
# networks:
# - appnet
暂无答案!
目前还没有任何答案,快来回答吧!