This post serves as personal persisted notes about the continuous small tweaks I make to develop efficiently in the Ubuntu terminal on Windows.
So let’s get started!
Let’s see, I installed Ubuntu from the Windows Store. Then I had some problems with the Linux subsystem not being enabled, so I went to the Google mobile and found this link Install the Windows Subsystem for Linux. Then I was done!
gcloud: command not found
Well sh…. I didn’t have any tools, I could of course just sudo apt-get everything -y
because I can clearly just flush the Ubuntu installation… but what if I wanted to keep my Ubuntu clean as well?
Enter one of my biggest idols, Jessie Frazelle. “The worst thing you could do to me is install something directly on my host”, hangs vividly in my mind as a variation of something she said at a talk at DockerCon, some years ago.
Containerize everything!
Gul’dan: “You will all keep your hosts clean!”
Grom Hellscream: “.. and what Gul’dan, must we containerize in return?”
Okay, maybe I remember it a little differently, get carried away with the clip below:
These days every honest piece of software has a companion container-image, that you can just run out of the box and everything will work! enough with the </sarcasm> it transfers badly in writing.
First things first anyways, I now had to get Docker working in the Ubuntu terminal; luckily someone’d already prepared everything.
It just keeps getting better, I’m officially out of my #VMware Ubuntu box, and straight into my #Ubuntu #Linux #Subsystem, using #VSCode for editing and #Docker for my tools 😀 https://t.co/t6vve2xhgc
— Nicolaj Figaw (@figaw) 16. maj 2018
Have trouble mounting containers in the Ubuntu terminal for Windows 10, with the Linux Subsystem? Check this out:https://t.co/RGuMF6DJ6z
— Nicolaj Figaw (@figaw) 26. maj 2018
“Building” my tools
Then I had to tweak some tooling, to quite get where I wanted to be, like the one below
gcloud sdk
Had a blast at #KubeCon #CloudNativeCon and got very! inspired by the wonderful @lizrice to (continue) not running containers as root! I made this tonight, https://t.co/HtagOiYpgL #securityisnotafeature #iamnotroot #docker #kubernetes #k8s
— Nicolaj Figaw (@figaw) 14. maj 2018
npm
$ alias npm='docker run --rm -it --network host \ -v "$PWD":/node \ node:10.1.0-alpine \ npm --prefix /node'
$ npm install
$ npm run <script>
node
$ function node() { docker run --rm -it --network host \ -v "$PWD":/node \ node:10.1.0-alpine \ sh -c "cd /node && node $@"; }
$ node index.js
Resources
~/.bash_profile
export DOCKER_HOST=localhost:2375 # NodeJS development # npm ## run node-alpine image, ## mount current folder into /node ## run npm with the /node folder alias npm='docker run --rm -it --network host \ -v "$PWD":/node \ node:10.1.0-alpine \ npm --prefix /node' # node ## run node-alpine image, ## mount current folder into /node ## cd into /node folder ## pass arguments to node function node() { docker run --rm -it --network host \ -v "$PWD":/node \ node:10.1.0-alpine \ sh -c "cd /node && node $@"; }
Make the whole thing a little nicer
Anyone: I don’t think..
Me: nice is subjective!
Not gonna create an account to “clap” for this, but hails to the ye-yah! https://t.co/9WUjCcUB2g
— Nicolaj Figaw (@figaw) 14. maj 2018
But why?
I always add this. Historically I’ve always liked to “keep my host clean”. I studied Computer Science with 3-month courses and had to install all kinds of random tools we’d use a couple of times, and every summer holiday would just include a mandatory format. After learning about VM’s I started using those to isolate the clutter, and now I’m trying this.