{"id":207,"date":"2021-09-05T13:54:36","date_gmt":"2021-09-05T13:54:36","guid":{"rendered":"https:\/\/magebrew.com\/blog\/?p=207"},"modified":"2021-09-05T13:54:36","modified_gmt":"2021-09-05T13:54:36","slug":"configure-xdebug-on-remote-docker-container","status":"publish","type":"post","link":"https:\/\/magebrew.com\/blog\/configure-xdebug-on-remote-docker-container\/","title":{"rendered":"Configure xDebug on remote docker container"},"content":{"rendered":"\n<p>Docker is widely used for WEB development. However on Mac running such a heavy application as Magento 2 in Docker is not very smooth. Because Docker runs on Linux much better I tried setup everything on remote Ubuntu machine and have only IDE on Mac. In this article I would like to share my experience with configuring xDebug on such setup.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Speaking about Magento 2 and Docker I highly recommend <a href=\"https:\/\/github.com\/davidalger\/warden\">Warden<\/a> tool. With Warden it is super easy to install and run any version of  Magento 2. <\/p>\n\n\n\n<p>In my current setup with help of Warden I run Magento 2 in docker container on a remote Ubuntu machine. On Mac I need only IDE (PHPStorm) and files. Files can be synced using SFTP (PHPStorm can upload files automatically) or Mutagen.<\/p>\n\n\n\n<p>While most of things in this to setup are easy to configure it took me some time to make xDebug working. <\/p>\n\n\n\n<p>I thought that opening a simple SSH tunnel would work:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh -R 9003:localhost:9003 user@server.com\n#xDebug 3 is using 9003 port<\/pre>\n\n\n\n<p>But unfortunately it doesn&#8217;t work. XDebug could not reach PHPStorm client on Mac.<\/p>\n\n\n\n<p>Eventually I come to the solution that worked.<\/p>\n\n\n\n<p>1.  On Docker host machine (Ubuntu) forward port 9003 to another port (e. g. 9000).<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh -g -L 9003:localhost:9000 127.0.0.1<\/pre>\n\n\n\n<p>2. Then on Mac open SSH tunnel:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh -R 9000:localhost:9000 user@ubuntu<\/pre>\n\n\n\n<p>That is it. <\/p>\n\n\n\n<p>If PHPStorm is configured properly (see instructions for <a href=\"https:\/\/docs.warden.dev\/configuration\/xdebug.html\">Warden<\/a>) xDebug now should work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker is widely used for WEB development. However on Mac running such a heavy application as Magento 2 in Docker is not very smooth. Because Docker runs on Linux much better I tried setup everything on remote Ubuntu machine and have only IDE on Mac. In this article I would like to share my experience &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/magebrew.com\/blog\/configure-xdebug-on-remote-docker-container\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Configure xDebug on remote docker container&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,19],"tags":[16,20,18],"_links":{"self":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts\/207"}],"collection":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":2,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions\/209"}],"wp:attachment":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}