Slight change to what this blog is about… The original two posts are still technically true, but I’m gonna change my focus to recording and reporting the technologies that I am trying to learn. I need a place to re-iterate what “my teachers” say, which will hopefully re-inforce the newly acquired data. If you can learn something from my ranting, that’s great!
I’m working through a TechWorld with Nana’s great video “Docker Tutorial for Beginners [FULL COURSE in 3 Hours]“, because I want to leave XAMPP/WAMP in the wastebucket and use Docker to completely run my dev environment.
But the article that really clicked for me and wow-ed me was “Dock Life: Using Docker for All The Things!“. The article is about using Docker to spin up containers for certain tools or packages that I need, but don’t want to install. OR… What about if I need specific version of those tools or packages. Well, following the steps in this article, you can do just that.
I had no problem setting up “aliases” for these commands in my WSL Ubuntu instance. At least after following the steps to get Docker commands to run in WSL. See “Get started with Docker remote containers on WSL 2“.
But what if I want to do the same thing in Powershell? Powershell lets you create aliases, but not the same way that you do it in Ubuntu. First I had to create a “function”.
function Start-Node {docker run --rm -it -v `pwd`:/app -w /app node:16-alpine @args }
After the function has been created (make sure to notice the @args
[thanks to StackOverflow for that one]), you can create the alias.
Set-Alias -Name node -Value Start-Node
So, a couple extra steps, but now I can run the following command without NodeJS being installed!
node -v
I think that’s awesome! And you should too!
UPDATE: To make the Powershell aliases stick permanently, make sure to store them in a profile.ps1 file. Check out “How to create permanent PowerShell Aliases“. And for the WSL, see “Creating aliases in Windows Subsystem for Linux“.