Just one thing, I'm stuck on where we setup the network. I've created my network with
docker network create --driver bridge isolated
and then ran my containers with
docker run -d -p 8000:3000 --net isolated --name jayy jayywalker/node
docker run -p 8001:3306 --net isolated --name db -e MYSQL_ROOT_PASSWORD=dddd -d mysql
Of course since I've ran the app container before the mysql it won't find it, but even after restarting the app container I receive the following error:
/app/app.js:13
throw err
^
Error: connect ETIMEDOUT
at Connection._handleConnectTimeout (/app/node_modules/mysql/lib/Connection.js:412:13)
at Object.onceWrapper (events.js:281:20)
at Socket.emit (events.js:193:13)
at Socket._onTimeout (net.js:450:8)
at listOnTimeout (internal/timers.js:535:17)
at processTimers (internal/timers.js:479:7)
--------------------
at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/app/node_modules/mysql/lib/Connection.js:119:18)
at Object.<anonymous> (/app/app.js:11:5)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
at internal/main/run_main_module.js:21:11
What string are you using as host in the node app? I've noticed that when you use networks instead of links you have to reference to other containers inside the networks by their names.
Hey, nice work!
Just one thing, I'm stuck on where we setup the network. I've created my network with
docker network create --driver bridge isolated
and then ran my containers with
docker run -d -p 8000:3000 --net isolated --name jayy jayywalker/node
docker run -p 8001:3306 --net isolated --name db -e MYSQL_ROOT_PASSWORD=dddd -d mysql
Of course since I've ran the app container before the mysql it won't find it, but even after restarting the app container I receive the following error:
It worked fine using link.
What string are you using as host in the node app? I've noticed that when you use networks instead of links you have to reference to other containers inside the networks by their names.
This needs mentioning in the article, at the end of the "Expand our knowledge on linking — there is another way" section.
thanks for the feedback Johan.. Haven't had time to update... But yes will look into improving this section
hi Jordan. Thanks for your comment. Let me get back to you in a couple of days
you should be using the name of the mysql container as host property
I am getting the same error even after I have set the host property as "mysql". Could you please point where I am going wrong?
Thanks for reaching out Mayank. Let m get back to you shortly