Created
January 3, 2016 13:59
-
-
Save donnykurnia/78baf2d6319007ae38eb to your computer and use it in GitHub Desktop.
Access mysql in other container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql: | |
image: mysql:latest | |
container_name: mysql | |
environment: | |
- MYSQL_ROOT_PASSWORD=root_password | |
- MYSQL_USER=user | |
- MYSQL_PASSWORD=user_pass | |
- MYSQL_DATABASE=user_db | |
app: | |
image: mysql:latest | |
container_name: example_app | |
links: | |
- mysql:db | |
command: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose run app | |
Creating mysql | |
root@cd9cf6553130:/# mysql -h "$DB_PORT_3306_TCP_ADDR" -P "$DB_PORT_3306_TCP_PORT" -u "$DB_ENV_MYSQL_USER" --password="$DB_ENV_MYSQL_PASSWORD" $DB_ENV_MYSQL_DATABASE | |
mysql: [Warning] Using a password on the command line interface can be insecure. | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 2 | |
Server version: 5.7.10 MySQL Community Server (GPL) | |
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. | |
Oracle is a registered trademark of Oracle Corporation and/or its | |
affiliates. Other names may be trademarks of their respective | |
owners. | |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> exit | |
Bye | |
root@cd9cf6553130:/# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment