PHPStorm Docker support for docker-compose network
I may be doing this incorrectly. I have attempted to read all of the documentation (which I'm referencing) relating to this, so if there is something I've missed please advise.
context(PHPStorm 2017.2): I have a set up where I need to interact with multiple containers: Nginx + PHPfpm + MySQL + Python + RabbitMQ. I use docker compose to orchestrate their interaction and they all occupy the network "project_default". I've set up the Python interaction in PyCharm successfully and I thought it would be similar for PHPStorm. It is somewhat different. In fact, I don't know where the CLI interpreter is even used. In PyCharm you reference the CLI interpreter from the Run Configuration and so when I set the "Network Mode" it takes. In PHPStorm it is not referenced nor does it take(which can be verified via the `docker inspect <container_name>` command which shows I'm still part of the default network). Either way I thought there might be some magic going on so I did configure the CLI interpreter with the Network Mode set to my desired network (among other things like volumes). These details are not used. I had to set it all up again via the "Edit Configurations" menu which weirdly enough seems to mimic the CLI interpreter set up on the "Container" sub menu with one notable field missing, "Network Mode".
After fiddling a lot I found that I could set many settings via the "CLI" option by supplying supported docker run CLI options. There is an issue with that feature also as it does not accept the `--network` option that I needed for my networks. GREAT. Fine, so I updated the `container_settings.json` file manually with the `NetworkMode` field and NOW it works. Docker inspect now reports the container as residing in the desired network and my services can communicate.
But I must be doing this wrong. Please help.
referenced:
- https://confluence.jetbrains.com/display/PhpStorm/Docker+Support+in+PhpStorm
- https://www.jetbrains.com/help/phpstorm/docker.html
- https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000058610-How-to-get-the-new-Docker-CLI-interpreter-to-connect-to-databases-in-other-containers
- http://webandapp.fr/blog/2017/09/where-is-my-database-host/
- https://blog.jetbrains.com/phpstorm/2016/11/docker-remote-interpreters/
- https://www.jetbrains.com/help/phpstorm/run-debug-configuration-docker-deployment.html
- https://www.jetbrains.com/help/phpstorm/configuring-remote-php-interpreters.html
- https://intellij-support.jetbrains.com/hc/en-us/community/posts/207941849-2016-3-EAP-Docker-linked-services-?page=1#community_comment_115000602690
Please sign in to leave a comment.
This was just recently implemented, see latest comments in https://youtrack.jetbrains.com/issue/IDEA-155549.
You might want to download 2017.3 Release Candidate and test this out.
I'll try it out -- also, the youtrack url linked doesn't show as available/valid to me.
A dot slipped into a link, fixed.
Sorry I hadn't got back -- yes this is much better than the previous way I was doing it. It's still different than the way it's done in pycharm but maybe that can't be helped. Thank you Dmitry!