Reputation: 436
I have a basic vagrant box, with docker and docker-compose running in it. The docker-compose.yaml has a web service like this:
web:
restart: always
build: .
ports:
- "5000:5000"
expose:
- "5000"
links:
- postgres:postgres
volumes:
- .:/usr/src/app/
env_file: .env
command: python manage.py runserver
#below the postgres service is defined
Vagrantfile:
Vagrant.configure(2) do |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 a Dockerfile with content: FROM python:3.5.1-onbuild
I installed the PyCharm 5.1 Professional Edition Beta 2 (build 145.256.43, March 11, 2016). I want to configure the interpreter of pycharm as the same which runs the web
service.
When I try to do so, in the "Configure remote python interpreter" dialog window, I select Docker Compose, then I add a new Docker server. When trying to add the docker server, when I put the ip of the vagrant machine + port 2376(this was the default in the input field) I get an exception:
screenshot
Are there any gotchas I am missing?
Upvotes: 3
Views: 1641
Reputation: 436
Okay I finally got it to work. Here's what I did:
/etc/default
, I opened the docker
file. Uncommented the DOCKER_OPTS
line and changed it to:DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"
In my Vagrantfile (the one which defines the VM on which the docker daemon is running, I changed the synced folders to
config.vm.synced_folder ".", "/vagrant", disabled: true # make sure you add this line
config.vm.synced_folder ".", "/home/georgi/Projects/ipad", # /home/georgi.... is the full path of the project on the host machine. This lines makes sure that the path of the project on the host and on the vm are the 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 the VM at this point.
tcp://192.168.33.69:2375
(the ip is the one defined in the Vagrantfile for the vm. The port is the one defined in the DOCKER_OPTS.) Leave the rest as it is. And press Ok.web
EDIT: I forgot to mention - I installed PyCharm 2016.1
EDIT 2017: Check out this or this. Newer versions of Docker seem to not accept the trick in the original answer.
Upvotes: 4