PHPStorm + docker + xdebug + db ssh tunnel











up vote
0
down vote

favorite












Locally I have following docker-compose configuration:



nginx:
build:
context: ./nginx
ports:
- "80:80"
volumes:
- ./../logs:/home/web/logs/
- ./../:/home/web/my-website.com/
depends_on:
- php
php:
build:
context: ./php
volumes:
- ./../:/home/web/my-website.com/
working_dir: /home/web/my-website.com/
expose:
- "8123"


php container has xdebug installed into it, I can easily connect to it from PHPStorm.
I have remote ClickHouse database which is connected via SSH Tunnel. When I start my container I just go into my container and execute:



ssh -4 login@host.com -p 2211 -L 8123:localhost:8123 -oStrictHostKeyChecking=no -Nf


After this, my site is able to use this connection, but when I execute console command



./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205


from PHPStorm, I'm getting an exception:



Failed to connect to 127.0.0.1 port 8123: Connection refused


If I jump into the container and launch the same command, everything works fine.



What's wrong? Why PHPStorm doesn't see my ssh tunnel?



UPD
I've changed host of clickhouse to docker container and changed php container definition to the following:



php:
build:
context: ./php
volumes:
- ./../:/home/web/my-website.com/
working_dir: /home/web/my-website.com/
expose:
- "8123"
ports:
- "8123:8123"


Now everything works










share|improve this question




























    up vote
    0
    down vote

    favorite












    Locally I have following docker-compose configuration:



    nginx:
    build:
    context: ./nginx
    ports:
    - "80:80"
    volumes:
    - ./../logs:/home/web/logs/
    - ./../:/home/web/my-website.com/
    depends_on:
    - php
    php:
    build:
    context: ./php
    volumes:
    - ./../:/home/web/my-website.com/
    working_dir: /home/web/my-website.com/
    expose:
    - "8123"


    php container has xdebug installed into it, I can easily connect to it from PHPStorm.
    I have remote ClickHouse database which is connected via SSH Tunnel. When I start my container I just go into my container and execute:



    ssh -4 login@host.com -p 2211 -L 8123:localhost:8123 -oStrictHostKeyChecking=no -Nf


    After this, my site is able to use this connection, but when I execute console command



    ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205


    from PHPStorm, I'm getting an exception:



    Failed to connect to 127.0.0.1 port 8123: Connection refused


    If I jump into the container and launch the same command, everything works fine.



    What's wrong? Why PHPStorm doesn't see my ssh tunnel?



    UPD
    I've changed host of clickhouse to docker container and changed php container definition to the following:



    php:
    build:
    context: ./php
    volumes:
    - ./../:/home/web/my-website.com/
    working_dir: /home/web/my-website.com/
    expose:
    - "8123"
    ports:
    - "8123:8123"


    Now everything works










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Locally I have following docker-compose configuration:



      nginx:
      build:
      context: ./nginx
      ports:
      - "80:80"
      volumes:
      - ./../logs:/home/web/logs/
      - ./../:/home/web/my-website.com/
      depends_on:
      - php
      php:
      build:
      context: ./php
      volumes:
      - ./../:/home/web/my-website.com/
      working_dir: /home/web/my-website.com/
      expose:
      - "8123"


      php container has xdebug installed into it, I can easily connect to it from PHPStorm.
      I have remote ClickHouse database which is connected via SSH Tunnel. When I start my container I just go into my container and execute:



      ssh -4 login@host.com -p 2211 -L 8123:localhost:8123 -oStrictHostKeyChecking=no -Nf


      After this, my site is able to use this connection, but when I execute console command



      ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205


      from PHPStorm, I'm getting an exception:



      Failed to connect to 127.0.0.1 port 8123: Connection refused


      If I jump into the container and launch the same command, everything works fine.



      What's wrong? Why PHPStorm doesn't see my ssh tunnel?



      UPD
      I've changed host of clickhouse to docker container and changed php container definition to the following:



      php:
      build:
      context: ./php
      volumes:
      - ./../:/home/web/my-website.com/
      working_dir: /home/web/my-website.com/
      expose:
      - "8123"
      ports:
      - "8123:8123"


      Now everything works










      share|improve this question















      Locally I have following docker-compose configuration:



      nginx:
      build:
      context: ./nginx
      ports:
      - "80:80"
      volumes:
      - ./../logs:/home/web/logs/
      - ./../:/home/web/my-website.com/
      depends_on:
      - php
      php:
      build:
      context: ./php
      volumes:
      - ./../:/home/web/my-website.com/
      working_dir: /home/web/my-website.com/
      expose:
      - "8123"


      php container has xdebug installed into it, I can easily connect to it from PHPStorm.
      I have remote ClickHouse database which is connected via SSH Tunnel. When I start my container I just go into my container and execute:



      ssh -4 login@host.com -p 2211 -L 8123:localhost:8123 -oStrictHostKeyChecking=no -Nf


      After this, my site is able to use this connection, but when I execute console command



      ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205


      from PHPStorm, I'm getting an exception:



      Failed to connect to 127.0.0.1 port 8123: Connection refused


      If I jump into the container and launch the same command, everything works fine.



      What's wrong? Why PHPStorm doesn't see my ssh tunnel?



      UPD
      I've changed host of clickhouse to docker container and changed php container definition to the following:



      php:
      build:
      context: ./php
      volumes:
      - ./../:/home/web/my-website.com/
      working_dir: /home/web/my-website.com/
      expose:
      - "8123"
      ports:
      - "8123:8123"


      Now everything works







      docker ssh-tunnel phpstorm xdebug






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 at 9:43

























      asked Nov 11 at 13:35









      Nikita Leshchev

      1034




      1034






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Your ssh tunnel is created inside your container on the socket 127.0.0.1:8123. You expose Port 8123 to the Host (maybe you should expose 127.0.0.1:8123). But the actual problem is that you try to Access 127.0.0.1:8123 from your Host machine, whereas you should access <ContainerIP>:8123.



          You could try to change the network_mode use the network_mode: "host" in your compose file as a solution.






          share|improve this answer

















          • 1




            Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
            – Nikita Leshchev
            Nov 17 at 9:40











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1374463%2fphpstorm-docker-xdebug-db-ssh-tunnel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          Your ssh tunnel is created inside your container on the socket 127.0.0.1:8123. You expose Port 8123 to the Host (maybe you should expose 127.0.0.1:8123). But the actual problem is that you try to Access 127.0.0.1:8123 from your Host machine, whereas you should access <ContainerIP>:8123.



          You could try to change the network_mode use the network_mode: "host" in your compose file as a solution.






          share|improve this answer

















          • 1




            Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
            – Nikita Leshchev
            Nov 17 at 9:40















          up vote
          1
          down vote



          accepted










          Your ssh tunnel is created inside your container on the socket 127.0.0.1:8123. You expose Port 8123 to the Host (maybe you should expose 127.0.0.1:8123). But the actual problem is that you try to Access 127.0.0.1:8123 from your Host machine, whereas you should access <ContainerIP>:8123.



          You could try to change the network_mode use the network_mode: "host" in your compose file as a solution.






          share|improve this answer

















          • 1




            Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
            – Nikita Leshchev
            Nov 17 at 9:40













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Your ssh tunnel is created inside your container on the socket 127.0.0.1:8123. You expose Port 8123 to the Host (maybe you should expose 127.0.0.1:8123). But the actual problem is that you try to Access 127.0.0.1:8123 from your Host machine, whereas you should access <ContainerIP>:8123.



          You could try to change the network_mode use the network_mode: "host" in your compose file as a solution.






          share|improve this answer












          Your ssh tunnel is created inside your container on the socket 127.0.0.1:8123. You expose Port 8123 to the Host (maybe you should expose 127.0.0.1:8123). But the actual problem is that you try to Access 127.0.0.1:8123 from your Host machine, whereas you should access <ContainerIP>:8123.



          You could try to change the network_mode use the network_mode: "host" in your compose file as a solution.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 at 11:24









          Ben

          1503




          1503








          • 1




            Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
            – Nikita Leshchev
            Nov 17 at 9:40














          • 1




            Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
            – Nikita Leshchev
            Nov 17 at 9:40








          1




          1




          Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
          – Nikita Leshchev
          Nov 17 at 9:40




          Thank you for your answer it helped me. But I have to add that I had to add ports node to the definition of php container. I add this edit to the question
          – Nikita Leshchev
          Nov 17 at 9:40


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1374463%2fphpstorm-docker-xdebug-db-ssh-tunnel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          AnyDesk - Fatal Program Failure

          How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

          QoS: MAC-Priority for clients behind a repeater