在容器Docker中进行开发是否可行/明智 [英] Is it possible/sane to develop within a container Docker

查看:160
本文介绍了在容器Docker中进行开发是否可行/明智的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手,我想知道是否有可能(也是一个好主意)在Docker容器中进行开发。
我的意思是创建一个容器,执行bash,安装并配置所需的一切,然后开始在容器内进行开发。

I'm new to Docker and was wondering if it was possible (and a good idea) to develop within a docker container. I mean create a container, execute bash, install and configure everything I need and start developping inside the container.

然后,该容器成为我的主机(对于CLI相关作品)。
在旅途中(或购买新机器时),我可以推开容器,然后将其拉到笔记本电脑上。

The container becomes then my main machine (for CLI related works). When I'm on the go (or when I buy a new machine), I can just push the container, and pull it on my laptop.

我还没有开始使用docker,所以这是现实的还是要避免的(磁盘问题/或拉/推定时问题)。

I haven't started using docker yet, so is it something realistic or to avoid (spacke disk problem and/or pull/push timing issue).

推荐答案

是。正确的设置是一个好主意。您将像运行虚拟机一样运行代码。

Yes. It is a good idea, with the correct set-up. You'll be running code as if it was a virtual machine.

用于创建构建系统的Dockerfile配置未完善,并且不会扩展shell变量,因此,安装应用程序可能有点乏味。另一方面,在构建自己的映像以创建新用户和工作环境之后,无需再次构建它,并且您可以使用run命令的-v参数挂载您自己的文件系统,这样您就可以主机和容器计算机中都需要的文件。

The Dockerfile configurations to create a build system is not polished and will not expand shell variables, so pre-installing applications may be a bit tedious. On the other hand after building your own image to create new users and working environment, it won't be necessary to build it again, plus you can mount your own file system with the -v parameter of the run command, so you can have the files you are going to need both in your host and container machine. It's versatile.

> sudo docker run -t -i -v
/home/user_name/Workspace/project:/home/user_name/Workspace/myproject <container-ID>

这篇关于在容器Docker中进行开发是否可行/明智的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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