It was pretty easy to set up a docker workstation that resembles the kind of env I use for node dev. I just needed to make a Dockerfile like this:
FROM ubuntu:latest # I don't remember why I needed to set up timezone, TBH . I probably just Googled it somewhere after some warning during build. ENV TZ=America/Winnipeg RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # I've just always used aptitude on Ubuntu. ag is just so much better than grep. etc. RUN apt update && apt install aptitude sudo git silversearcher-ag vim -y # This creates a new user for me. I prefer working with my own user instead of root. RUN useradd -rm -d /home/username -s /bin/bash -g root -G sudo -u 1000 username RUN echo 'username:password' | chpasswd
Build the image
From there you build the image with
docker build -t dannyb/my-dev . inside the dir with the Dockerfile. This takes a few minutes.
Start the instance
docker run -d dannyb/my-dev to start the instance. Now it’s ready to be connected to with VS Code.
Connecting with VS Code
For VS Code setup, I followed these instructions. Now I just open up VS code, press ctrl-shift-P and select the
Remote-Containers: Attach to Running Container... option. In the box that opens it will have all your running containers listed, along with the image they were created from. Select the one that says
dannyb/my-dev and it basically mounts it. Open up the terminal and you’re logged in as root into the docker instance! The first thing I run there is
su username to switch to my user, and
cd to go to the user’s home dir.
Setting up SSH key to be able to clone repos
After this is done, you can clone the repo. Once you’ve cloned the repo, press the “Open Folder” button in the Explorer sidebar of VS Code, and select the cloned repo dir. This actually restarts your terminal session, so just run
su username again to switch to your user.
That’s pretty much it
There are any number of other things I end up setting up, specific to my likes and needs of the project.