Rich editors in a Docker development environment

12,652

Solution 1

You should use an 'advanced' IDE like IntelliJ (Pycharm) and configure a remote Python SDK using SSH-Access to your App-Docker-Container (using a shared ssh-key to auth against the app-container with a preinstalled openssh server and preconfigured authorized_keys file). You can share this SDK information in your project file with all devs, so they wlll have this setup out of the box

1) This will ensure, your IDE knows about all the python libs/symbols available/installed in your docker-container during runtime. It will also enable you to properly debug remotely at the same time

2) This ensures, you have an IDE at your hand including a lot of important additional features like the inspector, 3way duff, search in path.. . hardly any of the Browser-Based IDEs will catch up with Pycharm at this point IMHO

Of course, as already mentioned in the comments, you need to share aka mount your code into the container. On linux, you plainly use host-volume-mounts from your local src folder to the container.

On OSX, you will run into performance issues when using host mounts. You might use something like http://docker-sync.io ( i am biased - there are also a lot of other similar tools )

Solution 2

I know this is an old question, but as I stumbled across it while trying to see what other editors might offer in this space, I would like to point out Visual Studio Code's notion of a Dev Container, which seems to provide the best level of integration I've seen for this so far. I'm hoping to see this turn into an industry trend myself.

Share:
12,652

Related videos on Youtube

Justin Harris
Author by

Justin Harris

Updated on July 17, 2022

Comments

  • Justin Harris
    Justin Harris almost 2 years

    So my team and I have bought into Docker - it is fantastic for deployment and testing. My real question is how to set up a great developer experience, specifically around writing Python apps, but this question could be generalized to nodejs, Java, etc.

    The problem: When writing a Python app, I really like having decent linting/autocomplete functionality, there are some really good editors out there (Atom, VSCode, PyCharm) that provide these, but most really want a Python install on the local disk. The real advantage of Docker is that all of the core language and any project libraries can all be in the container, so reproducing all of that on the host machine just for developing is a pain.

    I know that PyCharm pro does support Docker and docker-compose, but I found it quite sluggish and a lot of the test running capabilities were busted. On top of that, I really would like something that I can commit to version control so that the team can share dev setup and people don't have to repeat all of the steps for their own system.

    A few Ideas that I had were:

    1. Install an editor (like Atom) in a sidecar Docker container and use X11 forwarding
    2. Use a browser based editor such as https://c9.io/ in a container - this seems most promising
    3. Install some agent in a dev container that could handle autocomplete/linting, etc. and connect to it from a locally running editor - I think this would be the best solution, but I also think that right now it actually doesn't exist.

    Has anyone had luck setting up a more productive development environment besides just mounting volumes and editing text?

    • Matt Schuchard
      Matt Schuchard over 7 years
      Why not just run the editor locally and store the files in a shared volume so the changes propagate? This is the same kind of thing I would do with Vagrant.
    • Justin Harris
      Justin Harris over 7 years
      @MattSchuchard sure that works for main source files - what I am after is using the autocomplete/introspection to know about library files, which are in the docker container and not mounted as a volume.
    • Justin Harris
      Justin Harris over 7 years
      Yes they would be installed as part of creating the image. The issue isn't that they are changing, it is just that if the editor is installed on the host, and the libraries (and the specific python executable) are installed in the container, the editor cannot interrogate the libraries in order to provide autocomplete or linting assistance.
  • coredumperror
    coredumperror over 6 years
    This sounds like just what I need, but I don't really understand what you mean by a "remote Python SDK". Looking it up online, I've found docs from PyCharm about setting something like this up, but I have had no luck actually making it work. :(
  • Pitt
    Pitt about 6 years
    So you are suggesting to modify the Dockerfile of the app to include ssh and openssh server so you can tunnel to it from the IDE?
  • Jessi
    Jessi about 6 years
    What does "configure a remote Python SDK" mean?
  • lucid_dreamer
    lucid_dreamer almost 6 years
    @EugenMayer "So you are suggesting to modify the Dockerfile of the app to include ssh and openssh server so you can tunnel to it from the IDE? "
  • pawamoy
    pawamoy almost 6 years
    Maybe you could add the possibility to add a remote interpreter using Docker directly? As of end of 2017 and 2018, PyCharm now supports specifying an interpreter in a Docker image (and will then create and run a container when running/debugging). It saves us the need to install an SSH server in the Docker image, configure it and create a shared developer key for it.
  • Eugen Mayer
    Eugen Mayer almost 6 years
    I would say that does not suit the same need. while the new way gives you a. nice way to easily configure it without ssh and also have no local interpreter installed... it fails on the remote debugging part and especially on the symbols, since the interpreter is used from a different container or at leas not you running one... so the runtime container and the interpret. container can deverge too much. please take it as an IMHO since yet I just tried but never used dicker based interpreter