Fork of https://github.com/mkenney/docker-npm and fork of https://github.com/fernandoacorreia/docker-npm Please feel free to create an issue or open a pull request if you need support or would like to contribute.
2022-04-29
- add node v18
2021-11-17
- add node v16
2020-07-27
- add node v12 and v14, remove node < 8
Images are tagged according to the installed Node version and operating system. Package versions are not pinned, instead npm is executed to install current versions of each package. If stability issues arise, I will pin package versions in a Dockerfile for that Node/OS version and create a image tagged as stable based on it. Please let me know if you run into this situation.
Based on node:alpine. This image should be considered under development and may not be as stable as versioned images.
Based on node:14-alpine.
...
Based on node:latest. This image should be considered under development and may not be as stable as versioned images.
Based on node:14-bullseye.
...
The docker image includes a script (run-as-user) that allows commands to write files as either the current user or the owner/group of the current directory, which the shell scripts take advantage of to make sure files are created with your preferred permissions rather than root.
The images contain the latest stable bower, generate-md, grunt, gulp, node, npm, npx, and yarn, binaries for node.
The included run-as-user script has three methods of determining which uid and gid to execute as:
-
By default, it will execute with a
uidandgidthat matches the current directory (the one that gets mounted into/src). -
In order to take advantage of public key authentication when installing packages from private repositories, all the wrapper scripts will attempt to mount your
~/.sshdirectory into the container. When that is successful, the script will run as theuidandgidof the owner of~/.ssh(you).Most software that takes advantage of public key authentication protocols do so over SSH, and by default, send the current user name as the login name. Because this process is executing out of a segregated container, it knows nothing about the current user's name and will instead try to login as a user named
dev. In order to work around this, you need to create a SSH configuration that specifies the correct username.In your
~/.sshfolder create a file calledconfig. In that file you need to specify the correct username. For example, to specify your login name for all hosts:Host * User mkenneyYou can easily be more explicit as well, specifying by host or with additional wildcards. Google is your friend.
Host github.com User mkenney -
You can also explicitly specify the
uidandgidto use at runtime by defining thePUIDandPGIDenvironment variables when executing the container, this is quite useful in automated build systems:docker run \ --rm \ -it \ -v $(pwd):/src:rw \ -e "PUID=<user id>" \ -e "PGID=<group id>" \ mkenney/npm:latest <commands>
If you would to see like additional node modules and/or wrapper scripts added to this project please feel free to create an issue or open a pull request.