To run locally on your machine, you'll want to install Docker Desktop and start it up.
Once you've got Docker Destop running, you can run the following command to pull and start the image:
docker pull nodejs/devcontainer:nightly
docker run -it nodejs/devcontainer:nightly /bin/bash
Once you've run those commands, you'll be in a shell inside the running container. If you need to escape, type exit
. You should be good to jump to Working in the Container.
- The project is located at
/home/developer/nodejs/node
.- Once this directory is your active directory, you should be good to go.
- If you want to build the project in the container, run with ninja (rather than just make):
/home/developer/nodejs/node/configure --ninja && make -C /home/developer/nodejs/node
- You should be able to attach any editor that supports the concept of
devcontainers
to this
Assuming you've already got the Docker container running:
- Set the git
origin
to your own fork rather thannodejs/node
- Example, where
USERNAME
is your GitHub username:$ git remote set-url origin https://github.com/USERNAME/node.git
- Verify the remote is valid:
git remote -v
- Example, where
- Set up your git name and email
git config --global user.name "YOUR NAME"
git config --global user.email "[email protected]"
- Add your SSH key
- Preferably one that's already published to GitHub
- Alternatively, you can install the
gh
CLI and rungh auth login
to login and add a new key.
Some useful commands:
docker build .
- build the current Dockerfiledocker image ls
- list the images and IDsdocker run -it <image id> /bin/bash
- run a container and shell into itdocker tag <image id> devcontainer:nightly
- run to tag an image asnightly
Some notes on what's been helpful:
- Break up the
RUN
statement in the Dockerfile into multipleRUN
statements, each containing a single command. This provies more precise information about what exactly is failing if the Docker build fails and isn't providing helpful output. - Sometimes removing the
RUN
statement in the Dockerfile and runningdocker build
, running the built container, and individually running each command in the running container is a better development experience than working outside of the built container.