Configure PyCharm interpreter with docker-compose inside Vagrant -


i have basic vagrant box, docker , docker-compose running in it. docker-compose.yaml has web service this:

web:   restart:   build: .   ports:      - "5000:5000"   expose:     - "5000"   links:     - postgres:postgres   volumes:     - .:/usr/src/app/   env_file: .env   command: python manage.py runserver #below postgres service defined 

vagrantfile:

vagrant.configure(2) |config|    config.vm.box = "phusion/ubuntu-14.04-amd64"    config.vm.network "private_network", ip: "192.168.33.69"    config.vm.synced_folder ".", "/vagrant_data"   # provisioning 

the web service uses dockerfile content: from python:3.5.1-onbuild

i installed pycharm 5.1 professional edition beta 2 (build 145.256.43, march 11, 2016). want configure interpreter of pycharm same runs web service.
when try so, in "configure remote python interpreter" dialog window, select docker compose, add new docker server. when trying add docker server, when put ip of vagrant machine + port 2376(this default in input field) exception:
screenshot

are there gotchas missing?

okay got work. here's did:

  1. went vm, , in /etc/default, opened docker file. uncommented docker_opts line , changed to:
    docker_opts="-h tcp://0.0.0.0:2375 -h unix:///var/run/docker.sock"
  2. in vagrantfile (the 1 defines vm on docker daemon running, changed synced folders

    config.vm.synced_folder ".", "/vagrant", disabled: true # make sure add line config.vm.synced_folder ".", "/home/georgi/projects/ipad", # /home/georgi.... full path of project on host machine. lines makes sure path of project on host , on vm same.     owner: 'vagrant',     group: 'vagrant',     mount_options: ["dmode=777", "fmode=777"] config.vm.synced_folder "~/.pycharm2016.1/system/tmp", "/home/georgi/.pycharm2016.1/system/tmp",      owner: 'vagrant',     group: 'vagrant',     mount_options: ["dmode=777", "fmode=777"]   

    restart vm @ point.

  3. in pycharm, opened project, went file->settings->project->project interpreter->add remote. selected docker-compose.
  4. in server section, press new. enter api follows: tcp://192.168.33.69:2375 (the ip 1 defined in vagrantfile vm. port 1 defined in docker_opts.) leave rest is. , press ok.
  5. in configuration - select docker-compose.yaml - key part here - path of file should same @ host , vm.
  6. service name - in case - web
  7. voila

edit: forgot mention - installed pycharm 2016.1

edit 2017: check out this or this. newer versions of docker seem not accept trick in original answer.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -