Last active
August 29, 2015 14:17
-
-
Save booyaa/4d08da53f8501c096dd4 to your computer and use it in GitHub Desktop.
docker link issue
This file contains hidden or 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
#!/bin/bash | |
echo Creating MySQL data container | |
docker create --name foo-mysql-data -v /var/lib/mysql mysql:5.6 | |
echo 'Creating MySQL server container' | |
docker run --name foo-mysql --volumes-from foo-mysql-data -e MYSQL_ROOT_PASSWORD=password -d mysql:5.6 | |
echo 1st attempt to create database, will fail without sleep | |
#Error follows: | |
#Warning: Using a password on the command line interface can be insecure. | |
#mysqladmin: connect to server at 'mysql' failed | |
#error: 'Can't connect to MySQL server on 'mysql' (111)' | |
#Check that mysqld is running on mysql and that the port is 3306. | |
#You can check this by doing 'telnet mysql 3306' | |
docker run -it --rm --link foo-mysql:mysql mysql:5.6 /bin/bash -c 'mysqladmin --host=mysql --password=$MYSQL_ENV_MYSQL_ROOT_PASSWORD create wordpress' | |
echo 2nd attempt to create database, will pass with sleep | |
docker run -it --rm --link foo-mysql:mysql mysql:5.6 /bin/bash -c 'sleep 10 && mysqladmin --host=mysql --password=$MYSQL_ENV_MYSQL_ROOT_PASSWORD create wordpress' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment