Your problem can be fixed by following some steps.
Firstly, you can fetch your machine’s IP address with the command ifconfig.
Secondly, you can replace localhosts in query.js with the fetched IP.
The chain code should execute. However, if you are using Docker Toolbox, you can use the command docker -machine ls to fetch the IP address. Then you can copy that IP address to your URL column and paste the same to all localhosts in query.js & invoke.js files.