Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rich editors in a Docker development environment

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?

like image 365
Justin Harris Avatar asked Dec 24 '16 14:12

Justin Harris


People also ask

What is a Docker development environment?

Docker Dev Environments allows you to define the tooling, dependencies, and runtime stack to develop your app inside a container. And it's a container that you can use yourself or share with others. In the end, it's all about collaboration. But you aren't sharing an image that you have to push and pull.

What are Docker environments?

Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allows you to run many containers simultaneously on a given host.

Does Docker improve developer Quality?

And it does it all with a single descriptive YAML file, improves the development experience, speeds software delivery and boosts performance. And because Docker is an open platform, anyone can contribute to its development to build out features that aren't yet available.


3 Answers

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 )

like image 177
Eugen Mayer Avatar answered Oct 27 '22 16:10

Eugen Mayer


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.

like image 43
Cameron Kerr Avatar answered Oct 27 '22 15:10

Cameron Kerr


Could use x11docker

  • x11docker allows to run graphical desktop applications (and entire desktops) in Docker Linux containers.
  • Docker allows to run applications in an isolated container environment. Containers need much less resources than virtual machines for similar tasks.
  • Docker does not provide a display server that would allow to run applications with a graphical user interface.
  • x11docker fills the gap. It runs an X display server on the host system and provides it to Docker containers.
  • Additionally x11docker does some security setup to enhance container isolation and to avoid X security leaks. This allows a sandbox environment that fairly well protects the host system from possibly malicious or buggy software.
  1. https://github.com/mviereck/x11docker
  2. https://github.com/mviereck/x11docker/wiki (extensive! knowledge)
  3. https://dev.to/brickpop/my-dream-come-true-launching-gui-docker-sessions-with-dx11-in-seconds-1a53
like image 38
SemanticBeeng Avatar answered Oct 27 '22 16:10

SemanticBeeng