PhpStorm + Docker + Xdebug + DB SSH tunnel












1














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?










share|improve this question
























  • Running it in PhpStorm equals running it using your machine's terminal: the command isn't run inside of a container. I would assume that running ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205 in a console of your workstation would also fail? Btw, are you running this command simply in Terminal or you're doing Tools > Start SSH Session... > etc?
    – Ástþór
    Nov 12 at 10:36










  • @Ástþór, as far as I know, PhpStorm uses an interpreter, which I set in project settings. In my case, it uses interpreter from docker container, on my workstation no PHP installed. According to your second question, firstly I execute command docker exec -u www-data -it docker_php_1 /bin/bash and only then I execute command ./yii analysis/start-charts ...
    – Nikita Leshchev
    Nov 14 at 9:22


















1














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?










share|improve this question
























  • Running it in PhpStorm equals running it using your machine's terminal: the command isn't run inside of a container. I would assume that running ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205 in a console of your workstation would also fail? Btw, are you running this command simply in Terminal or you're doing Tools > Start SSH Session... > etc?
    – Ástþór
    Nov 12 at 10:36










  • @Ástþór, as far as I know, PhpStorm uses an interpreter, which I set in project settings. In my case, it uses interpreter from docker container, on my workstation no PHP installed. According to your second question, firstly I execute command docker exec -u www-data -it docker_php_1 /bin/bash and only then I execute command ./yii analysis/start-charts ...
    – Nikita Leshchev
    Nov 14 at 9:22
















1












1








1







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?










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?







php docker phpstorm xdebug ssh-tunnel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 13:43









LazyOne

106k21240258




106k21240258










asked Nov 11 at 13:12









Nikita Leshchev

1,047620




1,047620












  • Running it in PhpStorm equals running it using your machine's terminal: the command isn't run inside of a container. I would assume that running ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205 in a console of your workstation would also fail? Btw, are you running this command simply in Terminal or you're doing Tools > Start SSH Session... > etc?
    – Ástþór
    Nov 12 at 10:36










  • @Ástþór, as far as I know, PhpStorm uses an interpreter, which I set in project settings. In my case, it uses interpreter from docker container, on my workstation no PHP installed. According to your second question, firstly I execute command docker exec -u www-data -it docker_php_1 /bin/bash and only then I execute command ./yii analysis/start-charts ...
    – Nikita Leshchev
    Nov 14 at 9:22




















  • Running it in PhpStorm equals running it using your machine's terminal: the command isn't run inside of a container. I would assume that running ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205 in a console of your workstation would also fail? Btw, are you running this command simply in Terminal or you're doing Tools > Start SSH Session... > etc?
    – Ástþór
    Nov 12 at 10:36










  • @Ástþór, as far as I know, PhpStorm uses an interpreter, which I set in project settings. In my case, it uses interpreter from docker container, on my workstation no PHP installed. According to your second question, firstly I execute command docker exec -u www-data -it docker_php_1 /bin/bash and only then I execute command ./yii analysis/start-charts ...
    – Nikita Leshchev
    Nov 14 at 9:22


















Running it in PhpStorm equals running it using your machine's terminal: the command isn't run inside of a container. I would assume that running ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205 in a console of your workstation would also fail? Btw, are you running this command simply in Terminal or you're doing Tools > Start SSH Session... > etc?
– Ástþór
Nov 12 at 10:36




Running it in PhpStorm equals running it using your machine's terminal: the command isn't run inside of a container. I would assume that running ./yii analysis/start-charts 003b56fe-db47-11e8-bcc0-52540010e5bc 205 in a console of your workstation would also fail? Btw, are you running this command simply in Terminal or you're doing Tools > Start SSH Session... > etc?
– Ástþór
Nov 12 at 10:36












@Ástþór, as far as I know, PhpStorm uses an interpreter, which I set in project settings. In my case, it uses interpreter from docker container, on my workstation no PHP installed. According to your second question, firstly I execute command docker exec -u www-data -it docker_php_1 /bin/bash and only then I execute command ./yii analysis/start-charts ...
– Nikita Leshchev
Nov 14 at 9:22






@Ástþór, as far as I know, PhpStorm uses an interpreter, which I set in project settings. In my case, it uses interpreter from docker container, on my workstation no PHP installed. According to your second question, firstly I execute command docker exec -u www-data -it docker_php_1 /bin/bash and only then I execute command ./yii analysis/start-charts ...
– Nikita Leshchev
Nov 14 at 9:22














1 Answer
1






active

oldest

votes


















0














I've got an answer on "superuser" site: https://superuser.com/questions/1374463/phpstorm-docker-xdebug-db-ssh-tunnel/1375961#1375961



Besides, I've added ports node to my php container definition, now it's the following:



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





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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',
    autoActivateHeartbeat: false,
    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%2fstackoverflow.com%2fquestions%2f53249075%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









    0














    I've got an answer on "superuser" site: https://superuser.com/questions/1374463/phpstorm-docker-xdebug-db-ssh-tunnel/1375961#1375961



    Besides, I've added ports node to my php container definition, now it's the following:



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





    share|improve this answer


























      0














      I've got an answer on "superuser" site: https://superuser.com/questions/1374463/phpstorm-docker-xdebug-db-ssh-tunnel/1375961#1375961



      Besides, I've added ports node to my php container definition, now it's the following:



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





      share|improve this answer
























        0












        0








        0






        I've got an answer on "superuser" site: https://superuser.com/questions/1374463/phpstorm-docker-xdebug-db-ssh-tunnel/1375961#1375961



        Besides, I've added ports node to my php container definition, now it's the following:



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





        share|improve this answer












        I've got an answer on "superuser" site: https://superuser.com/questions/1374463/phpstorm-docker-xdebug-db-ssh-tunnel/1375961#1375961



        Besides, I've added ports node to my php container definition, now it's the following:



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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 at 9:38









        Nikita Leshchev

        1,047620




        1,047620






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249075%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







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini