DEV Community

Cover image for Dockerize your Development Environment

Dockerize your Development Environment

Niall Maher on April 15, 2020

With Visual Studio Code A problem I had within our teams in my last gig was running projects consistently across multiple operating syst...
Collapse
 
jefflindholm profile image
Jeff Lindholm

Using powershell:
I just do dev-here node:latest it will download the image mount the current directory to /code in the container and you can edit locally update to git etc. Works for any container that you want, I use it for rust, donet core, node, etc.

function dev-here($lang, $port = 8000) {
    if ($lang -eq '') {
        echo 'usage is dev-here <container name>'
        return
    }
    $args = 'bash'
    if ($lang -eq 'python') {
        $args = "bash"
        # $args = "bash -c 'cd code && pip install -r requirements.txt && bash'"
    }
    $msg = $lang + ' opening port ' + $port + ' running ' + $args
    echo $msg
    echo "docker run --rm -it -e USER=dev -p ${port}:${port} -v ${PWD}:/code $lang $args"
    docker run --rm -it -e USER=dev -p ${port}:${port} -v ${PWD}:/code $lang $args
}
Collapse
 
nialljoemaher profile image
Niall Maher

Nice well then all this article would give you is all the plugins out of the box too. This is a really smart script 💜

Collapse
 
erikthered profile image
Erik Nelson

Nice post, I was going to write one along these lines but now I don't have to!

I actually prefer this workflow in lieu using rvm, nvm, etc. these days. You can use a Docker Compose file too, which is handy for apps with more complicated dependencies.

Collapse
 
nialljoemaher profile image
Niall Maher

I do the exact same! I'm wondering why more OSS communities don't do the same. It's such an easy way to get up and running.

Collapse
 
nicolasmendonca profile image
Niko Mendo

Excellent article, man. Super useful and super easy.

Collapse
 
nialljoemaher profile image
Niall Maher

Thanks!

Collapse
 
codeur47 profile image
YORO Ange Carmel

Thank for the useful post

Collapse
 
nialljoemaher profile image
Niall Maher

Glad it was useful at least 💜

Collapse
 
rberrelleza profile image
Ramiro Berrelleza • Edited

This is pretty cool, love the format! I'm the maintainer of a couple of open source projects focused on moving dev environments to containers in Kubernetes, would love your thoughts on them!

Collapse
 
nialljoemaher profile image
Niall Maher

Oh nice I'll take a look over the day 😁

Collapse
 
andrweisr profile image
AndrWeisR

The source of your app is in the container, right? How do you update the source in an external repo? Do you just push to github from within the container?
Do you have visibility of the source files in the host operating system?

Collapse
 
niro profile image
Arnau

What theme are you using in VScode?

Collapse
 
nialljoemaher profile image
Niall Maher

Synthwave '84 personally, but for the video, I think I used Cobalt

Collapse
 
niro profile image
Arnau

Thanks! These are awesome :)

Collapse
 
anibalardid profile image
Anibal

Hi !
Devilbox is a great alternative to newbies, to use Docker with some benefits and very easy

Collapse
 
nialljoemaher profile image
Niall Maher

I've never seen Devilbox before I will take a look

Collapse
 
anibalardid profile image
Anibal

I've been using it for a long time. It's very comfortable to use ;)
I use docker and kubernetes standalone too, but to my PHP development environment I use devilbox :)

Collapse
 
lukebillo profile image
LukeBillo

Excellent post! I think you're one of the first people I've seen put both video and text explanation- although I don't exactly go far and wide around dev.to.

The extra effort is greatly appreciated, as I usually like to read first and watch later when I know I'm interested. Thanks :)

Collapse
 
nialljoemaher profile image
Niall Maher

Thanks! I know I learn better from video so that's why 😂

Collapse
 
timhub profile image
Tech Tim (@TechTim42)

docker is great, docker on non-linux is not

Collapse
 
nialljoemaher profile image
Niall Maher

They fixed it on Windows recently, it's worth trying again

Collapse
 
timhub profile image
Tech Tim (@TechTim42)

i am on mac, I do use docker everywhere, but I still feel it is much slower then on a linux os.

Thread Thread
 
nialljoemaher profile image
Niall Maher

I'm using a Mac too haven't actually used Docker on Linux so I have no idea how much faster it could be 😂

Collapse
 
bgauryy profile image
bgauryy

Great post!

Collapse
 
nialljoemaher profile image
Niall Maher

Thanks 💜