简体   繁体   English

osx中的Linux开发环境(作为mv或任何其他形式的docker)

[英]Linux dev environment in osx (docker as mv or any other)

I'd love to hear from you some advice on setting up what I'm looking for. 我很想听听您关于设置我要寻找的建议。

I'm using OSX and I need to develop some code on a Linux machine, the thing is that I was looking for some VM alternative since it takes too much battery power. 我正在使用OSX,并且需要在Linux机器上开发一些代码,但事实是我一直在寻找VM替代品,因为它消耗了过多的电池电量。

The first thing I come across with was a docker container. 我遇到的第一件事是一个docker容器。 I know It is not what it was designed for, but I thought it might work anyway. 我知道这不是它的设计目的,但我认为它可能仍然有效。 So I tried running a container as 所以我尝试运行一个容器

docker run -i -t ubuntu /bin/bash

and it worked well. 而且效果很好。 However all the changes I make are gone and I can't fins a way to solve it. 但是,我所做的所有更改均已消失,无法找到解决方法。 I also tried 我也试过

docker run -i -v /Users/JaimehRubiks/test:/home/Jaime -t ubuntu /bin/bash

and all files in there are saved (also very interesting because I can share my files with host), but it's kind of boring having to commit to the docker image if I change anything in the config files of my ubuntu. 并保存了其中的所有文件(这也非常有趣,因为我可以与主机共享文件),但是如果我更改了ubuntu的配置文件中的任何内容,那么不得不提交到docker镜像就有点无聊了。


What I'm looking for is just a simple way to run linux in my mac, and then access to it somehow, like I did in docker or via SSH. 我正在寻找的只是在Mac中运行linux的一种简单方法,然后以某种方式访问​​它,就像我在docker或通过SSH中所做的那样。

Docker currently does not run natively on osx as Docker relies on the Linux kernel for its isolation features. Docker当前不能在osx上本地运行,因为Docker的隔离功能依赖于Linux内核。 In fact, the Docker Toolbox uses a Virtual Box virtual machine running the boot2docker Linux distro to run the Docker daemon on osx. 实际上,Docker Toolbox使用运行boot2docker Linux发行版的Virtual Box虚拟机在osx上运行Docker守护程序。 See the official documentation on Mac osx installation. 请参阅有关Mac osx安装的官方文档

The boot2docker linux image is quite light weight, but I'm not sure you will get much benefit from running Docker on osx for Linux development over simply running a full Virtualbox machine with Ubuntu (or other distro). boot2docker linux映像的重量很轻,但是我不确定通过在osx上运行Docker进行Linux开发会比从Ubuntu(或其他发行版)上运行完整的Virtualbox机器获得更多收益。 If you want to run a virtual machine vagrant is a good tool to help you set that up. 如果您想运行虚拟机, vagrant是一个很好的工具,可以帮助您进行设置。 It lets you easily pull down images from an image repo, setup the image, and ssh into it. 它使您可以轻松地从图像存储库中提取图像,设置图像并ssh到其中。 It also makes host -> guest-machine folder sharing and port forwarding quite simple. 这也使主机->来宾机文件夹共享和端口转发变得非常简单。

but it's kind of boring having to commit to the docker image if I change anything in the config files of my ubuntu. 但是如果我更改了ubuntu的配置文件中的任何内容,那么不得不提交到docker镜像就很无聊了。

You don't have to docker commit anything: any file change make on the host ( /Users/JaimehRubiks/test ) will be visible in the container ( /home/Jaime ) 您无需docker提交任何内容:主机( /Users/JaimehRubiks/test )上的任何文件更改都会在容器( /home/Jaime )中显示

what about using vagrant to run Ubuntu or CentOS? 使用vagrant运行Ubuntu或CentOS怎么样? you can access the system via command vagrant ssh and configure it with configuration file and share it like using docker. 您可以通过命令vagrant ssh访问系统,并使用配置文件对其进行配置,并像使用docker一样共享它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM