Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use docker to isolate my development environment?

Tags:

docker

Ok, this drives me crazy. I've read a lot about Docker, and still can't understand - is docker for me...

I use Mac OS X for at work and vagrant to fire up a virtual machine with Ubuntu for development. I use vagrant for each project because I want to have the same os and libs as I use on production servers. I hate tools like rbenv and nvm because their usage increase terminal's start up time. If both are activated I need to wait 2..4 secs for a new terminal tab to be ready. I type fast and this delays kill my productivity.

I'm okay with vagrant but using virtualbox which requires ~800 mb of RAM for each VM... its too much.

So the question is: can I use docker in the same fashion as vagrant? Say I have two projects and I need to use Ruby 2.0 for the project A and Ruby 2.3 for the project B, is it possible/correct with docker to create two containers each with its own version of Ruby? And I don't want to these versions of Ruby intersect with system Ruby.

With vagrant I just create two VMs one with Ruby 2.0, and the second with Ruby 2.3 . If I don't need any of them I'll destroy VM and my system will stay clear without and software installed on the guest machine.

Edited: I know that I can't use Docker natively with OS X. Let's assume some Linux Ubuntu/Debian/Arch/etc. I'm ready to move to Linux, if I'll know that Linux+Docker will give me what I want.

like image 718
Nodari Lipartiya Avatar asked Jun 18 '16 11:06

Nodari Lipartiya


Video Answer


1 Answers

You can use Docker in Mac OS X using the new docker beta for Mac OS X. It still uses a VM but it is lighter than Virtualbox. Also, it supports better integration with OS X. As of now, it is slightly buggy.

To answer your question, yes you can create your environment with the runtime you need inside the docker container without it affecting other containers or the system for that matter. Do bear in mind that a container usually runs one process inside it, so don't expect to run multiple services like you would in a vagrant box. It is not an entire OS, it is merely an executable running in a different kernel namespace. If you want to run multiple processes, there are workarounds but the "correct" way to do it is using multiple containers connected together using something like docker-compose.

like image 119
khattam Avatar answered Nov 15 '22 03:11

khattam