在Docker容器上开发时使用IDE [英] Using an IDE while developing on a docker container

查看:418
本文介绍了在Docker容器上开发时使用IDE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 docker 容器开发应用程序时,我没有得到什么。



可以说我正在开发一个Java应用程序,并用jdk 8基本映像设置了一个Java容器,我仍然需要在本地开发计算机上安装java 8 jdk,因为我要使用的IDE将在本地计算机而不是docker容器上查找运行时库。



这是对的还是我缺少了什么?我可以完全在docker容器上完成某些操作,例如设置数据库,但有些事情我也必须在本地开发计算机上完成,并尝试将其与我的docker映像进行匹配,例如Java或python这样的语言运行时

解决方案

更新:



  • 2018/04/17:


    上面的图片来自 [ 2]


    设置本地开发环境时的限制



    可以说我正在开发一个Java应用程序,并用jdk 8基本映像设置了一个Java容器,我仍然需要在本地开发机器上安装java 8 jdk,因为我将要使用的IDE将寻找运行时。


    此选项可能会导致您已经提到的问题:它可能在您本地的开发环境,并在其他地方失败,因为您忘记添加库,广告外观,这是您在没有注意的情况下所做的微小更改,请记住将其添加到Docker环境中。


    您可以在开发时坚持使用Docker


    解决上述问题的一种方法是依靠docker [3] 来设置您要使用的环境。这意味着每次更改内容时,都将必须 docker build 一个新映像,并 docker run 一个新容器基于此图像。正如其他人提到的,要定义如何构建映像,您将必须使用 Dockerfiles 。而且,如果您的应用程序具有不同的互连容器,则必须在 docker-compose.yml 文件中定义所有这些(网络,链接,依赖项)。然后,重复的构建和运行过程将成为您IDE的工作...


    IDE&插件/附件


    来自 [1]


    < h3> IDE

    Docker版本未提供用于使用Docker开发的本机IDE 。主要接口是命令行API。但是,大多数领先的IDE(NetBeans,Eclipse,IntelliJ,Visual Studio)都通过插件或附加组件对Docker提供了一些支持。


    例如,从 [2]



    Docker Labs-开发人员工具教程


    您可以在此处找到一些根据情况(IDE,语言...)的准则:



    共享卷|热装| 观看对于文件更改


    我认为这种方法与您的标题在docker容器上开发 相匹配,并且我的意思是/理解某人正在跑步的情况具有共享卷的容器,并且只要代码中发生更改(使用IDE),这都会直接影响容器。也许这会在某些情况下有效,但在某些其他情况下会有所限制。


    我的来源是:



    There is something that I am not getting when developing an application while using docker containers.

    Lets say I am developing a java application and I set up a java container with jdk 8 base image, I still need to install java 8 jdk on my local development machine, since the IDE which I am going to use is going to look for runtime libraries on the local machine not the docker container.

    Is this right or am I missing something? Somethings I will be able to do entirely on the docker container like setting up a database but some things I will also have to do on my local development machine and try to match it up with my docker image for example a language runtime like java or python for the sake of using the IDE.

    解决方案

    Updates:


    Original post:

    There is something that I am not getting when developing an application while using docker containers.

    It's ok, this is not something trivial. Try to see the big picture, it's about creating a Development Pipeline (or CI/CD Pipeline if you like to use the terms Continuous Integration/Continuous Delivery).

    The above image is from [2]

    Limitations when setting-up a local dev environment

    Lets say I am developing a java application and I set up a java container with jdk 8 base image, I still need to install java 8 jdk on my local development machine, since the IDE which I am going to use is going to look for runtime libraries on the local machine not the docker container.

    This is an option that may cause you a problem already mentioned: it may work on your local dev environment and fail elsewhere because you forgot adding a library, a dependency, a minor change that you did without paying attention and keeping in mind to add it to your docker environment.

    You can stick to docker while developing

    An approach that solves the above problem is to rely on docker[3], in order to set-up the environment you want to use. This means that every time you change something, you will have to docker build a new image and docker run a new container based on this image. As others have mentioned, to define how your images are going to be built you will have to use Dockerfiles. And if your app has different interconnected containers you will have to define all these (networks, links, dependencies) inside a docker-compose.yml file. The repetitive process of building and running will then be your IDE's job...

    IDEs & plugins/add-ons

    from [1]:

    IDE

    Docker versions do not provide a native IDE for developing with Docker. The primary interface is the command line API. However, most leading IDEs (NetBeans, Eclipse, IntelliJ, Visual Studio) have some support for Docker through plugins or add-ons.

    For example, from [2]:

    Docker Labs - Developer Tools Tutorials

    You can find some guidelines depending on your case (IDE, language...) here:

    Shared Volumes | Hot reload | "watching" for file changes

    I think this approach matches with your title saying "developing on a docker container" and I mean/understand the case where someone has a running container with a shared volume and whenever a change happens in the code (using the IDE), this affects the container directly. Maybe this will work for a case and have limitations for some other cases. It is up to you to make your assessments and choose your path.

    My sources are:

    这篇关于在Docker容器上开发时使用IDE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆