Docker Community Forums

Share and learn in the Docker community.

Using pycharm docker plugin with docker beta

I would like to try to use the pycharm docker plugin to start docker containers in the docker for mac beta, but I have problems to set it up…

Is this currently possible at all ? I would need to set an api url (which would probably contain docker.local and certificates folder.

Thanks,
Bastian

5 Likes

I’m also interested in this.

Related issue on the PyCharm issue tracker: https://youtrack.jetbrains.com/issue/PY-19178

Hi,

The supported mechanism for talking to Docker for Mac is over the Unix socket at /var/run/docker.sock. Looking at the PyCharm stack trace - it appears to be written in Java. It seems that docker-java also supports communication over Unix sockets so this should be possible!

– Dave

I upgraded to
Docker for Mac Version 1.11.0-beta8 (build: 6072)
3c1bfeb0e86a9403f82302edfea4c4987cc2cb32
and the problem remains.
I don’t know if the problem is with PyCharm or Docker for Mac.

@stefanfoulis this is a PyCharm issue

Definitely a pycharm issue.

I was looking for an exposed ip like I use with docker-machine to develop for a workaround where could I find the ip? http://localhost:2356 doesn’t work like I imagine it would neither did 12.1.1.16, 192.168.99.1. Any advice would be appreciated.

I’m afraid unix:///var/run/docker.sock is the only supported method for talking to the Docker API when using Docker for Mac!

Temporary workaround is use local TCP port (tcp://127.0.0.1:2376) in pycharm docker settings and pipe TCP to UNIX socket.

I use socat:
$socat TCP-LISTEN:2376,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock

1 Like

That workaround opens port 2376 to the world… as TLS isn’t enabled, this is a bad idea as anyone on the same network can hijack your docker daemon

You might want to try this:

$ socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock

Port 2375 is still open to the world, but only connections from 127.0.0.1 are permitted. There may be a better option i.e don’t listen on all interfaces, but I’m not familiar enough with socat to advise.

The recommended fix would be for PyCharm to fix this in their code.

I tried socat, and it works for building images, but PyCharm fails with com.github.dockerjava.api.exception.InternalServerErrorException: EOF error trying to run container:

This must be more secure:
socat TCP-LISTEN:2376,reuseaddr,fork,bind=127.0.0.1 UNIX-CLIENT:/var/tmp/docker.sock

Anyway docker fails immediately after container starts. It return 500 error code and EOF
There is part of communication log between PyCharm and Docker (you can see it with -v socat option)

2016/05/15 02:05:13.424460 length=326 from=0 to=325
POST /containers/cd502cce0cd3f45880c5fc8b77785f540fc9883f9638b813444cad96fce8ea4f/start HTTP/1.1\r
Accept: application/json\r
Content-Type: application/json\r
User-Agent: Jersey/2.11 (Apache HttpClient 4.3.1)\r
Transfer-Encoding: chunked\r
Host: 127.0.0.1:2376\r
Connection: Keep-Alive\r
Accept-Encoding: gzip,deflate\r
\r
2\r
{}\r
0\r
\r
< 2016/05/15 02:05:13.429149 length=153 from=2248 to=2400
HTTP/1.1 200 OK\r
Content-Type: application/vnd.docker.raw-stream\r
Transfer-Encoding: identity\r
Date: Sat, 14 May 2016 21:05:13 GMT\r
Connection: close\r
\r
< 2016/05/15 02:05:13.472815 length=199 from=0 to=198
HTTP/1.1 500 Internal Server Error\r
Content-Length: 4\r
Content-Type: text/plain; charset=utf-8\r
Date: Sat, 14 May 2016 21:05:13 GMT\r
Server: Docker/1.11.1 (linux)\r
X-Content-Type-Options: nosniff\r
\r
< 2016/05/15 02:05:13.473179 length=4 from=199 to=202
EOF

What is the latest on Docker for Mac / PyCharm integration. I would like to deploy to a container that I have previously built, but cannot seem to get the settings correct…