I have a simple docker-compose.yml
$ cat docker-compose.yml
# Use root/example as user/password credentials
version: '3.1'
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
ports:
- 3306:3306
volumes:
- ./setup.sql:/docker-entrypoint-initdb.d/1-setup.sql
- ./data.sql:/docker-entrypoint-initdb.d/2-data.sql
adminer:
image: adminer
restart: always
ports:
- 8080:8080
cli:
image: mysql
links:
- db
command: mysql -hdb -P3306 -uroot -pexample
I can’t login mysql with below run command
docker-compose run --rm cli
Updates:
I am fine now. just wait and run the command again, I can login the database with mysql cli
docker-compose run --rm cli mysql -hdb -P3306 -uroot -pexample