11

I have the following docker-compose.yml file:

version: '2'
services:
    postgis:
        image: mdillon/postgis
        environment:
           POSTGRES_USER: ${POSTGIS_ENV_POSTGRES_USER}
           POSTGRES_PASSWORD: ${POSTGIS_ENV_POSTGRES_PASSWORD}
           POSTGRES_DB: ${POSTGIS_ENV_POSTGRES_DB}
        volumes:
            - /nexchange/database:/var/lib/postgresql/data
        restart: always
    app:
        image: onitsoft/nexchange:${DOCKER_IMAGE_TAG}
        volumes:
            - /nexchange/mediafiles:/usr/share/nginx/html/media
            - /nexchange/staticfiles:/usr/share/nginx/html/static
        links:
            - postgis
        restart: always
    web:
        image: onitsoft/nginx
        volumes:
            - /nexchange/etc/letsencrypt:/etc/letsencrypt
            - /nexchange/etc/nginx/ssl:/etc/nginx/ssl
            - /nexchange/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
            - /nexchange/mediafiles:/usr/share/nginx/html/media
            - /nexchange/staticfiles:/usr/share/nginx/html/static
        ports:
            - "80:80"
            - "443:443"            
        links:
            - app
        restart: always

For some reason, some functionalities that work on the local container do not work on staging. I would like to configure a remote interpreter in pycharm for staging, however it seems like this setup is not currently supported.

I am using wercker + docker compose and my IDE is pycharm.

EDIT: The question is: How to setup Pycharm debugger to run on a remote host running docker compose

Oleg Belousov
  • 9,981
  • 14
  • 72
  • 127
  • Is this an integration issue between your IDE and the application deployed using docker compose? – Mark O'Connor Sep 04 '16 at 09:31
  • Rather a missing feature in PyCharm that does not allow to use both SSH Tunnel + Docker API – Oleg Belousov Sep 04 '16 at 17:37
  • Can you clarify what you're asking? – Mano Marks Sep 08 '16 at 20:17
  • I am asking how to debug a remote machine which is running docker in pycharm, as simple as that... – Oleg Belousov Sep 08 '16 at 22:14
  • Is that correct that when run locally you point your debugger to `localhost:443` or `localhost:80` as these are the only ports exported from the setup to the host (explicitly in the above config)? If yes, you should point your debugger to `remotehost:443` or `remotehost:80` and make sure your firewall lets those ports to be accessed. If the above assumption is not correct, then how do you connect the debugger locally? – Oleg Sklyar Sep 08 '16 at 22:55
  • You arte wrong... Pycharm users dicker app to debug, and also starts a helper container for that purpose. – Oleg Belousov Sep 08 '16 at 22:57
  • @OlegTikhonov Well then, how is that helper container supposed to know about a docker environment running elsewhere remotely? Forget about docker, have your application run remotely, how would you connect pycham debugger? – Oleg Sklyar Sep 08 '16 at 23:20

1 Answers1

6

The solution, however not secure, is open the docker API on the remote target to public traffic via iptables (possibly to traffic only from specific IP, if you posses a static IP).

$ ssh $USER@staging.nexchnage.ru
oleg@nexchange-staging:~# sudo iptables -A INPUT -p tcp --dport 2376 -j ACCEPT
oleg@nexchange-staging:~# sudo /etc/init.d/iptables restart

And then simply use the docker compose feature of JetBrain PyCharm / PhpStrom or you favourite choice:

enter image description here

Cheers

Oleg Belousov
  • 9,981
  • 14
  • 72
  • 127