Hello currently I get in touch with Docker. I am doing their getting started and I ran into a problem which I cant solve and I dont understand why it dont work. First of all I create a network using.
$ docker network create todo-app
After that, I set up a Container mysql database and connect it with the network with following code.
$ docker run -d
--network todo-app --network-alias mysql
-v todo-mysql-data:/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=secret
-e MYSQL_DATABASE=todos
mysql:5.7
I check for the Container id with
$ docker ps
After that I use the command to get into the mysql CLI ? (not sure on that yet)
$ docker exec -it mysql -u root -p
After getting there I use
mysql> SHOW DATABASES;
to show all DB on my PC? But there is non listed named todos and i dont know why it dont appear.
I would like to hear what you are thinking im struggeling a little there. Thanks for the replies. Sorry for my english skills.
3
Answers
Sorry for the trouble it was my fault I guess cause I used the Command I pointed out above but I definetly had to use this command :
Because im using Linux... Such a dumb mistake but i swear this wasnt there two months ago when I asked this Qeustion.
Run container in the foreground and check the logs.
Following Part 7: Multi-container apps, I ran into this exact issue just now.
Chances are, you have run that same command at least once.
And the first time you ran the command you unknowingly made a mistake. For me, I mistyped
MYSQL_DATABASE
FORMYSQL_ROOT_PASSWORD
. Yours might be different. In any case, it seems making small mistakes like this might have caused themysql:5.7
image to not be set up correctly with thetodos
database. (Not entirely sure.)Adding to that, the first time you run that command, Docker creates a
todo-mysql-data
volume, which does not get overwritten when you run that same command again.So as a "fix", you might have to delete the
todo-mysql-data
volume first.And then re-create the
todo-mysql-data
volume implicitly by re-running the image with the above command; this time without mistakes.