You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can I change the username of the node user inside the Dockerfile to "dev"? Will that break things? #5125
Note that the node user is neither a build-time nor a run-time dependency and it can be removed or altered, as long as the functionality of the application you want to add to the container does not depend on it.
@nschonni I read that part. I just want to change the name of the user. This is my core image:
FROM node:lts-trixie-slim
RUN usermod -d /home/dev -l dev node
RUN sed -i 's/^Components: main$/& contrib non-free-firmware/' /etc/apt/sources.list.d/debian.sources \
&& apt-get update -qq -y \
&& apt-get upgrade -qq -y \
&& apt-get install -y --no-install-recommends \
git procps curl inotify-tools jq python3 make g++ unzip bc jo \
&& npm install --location=global npm npm-check \
&& cd /usr/local/bin && curl -fsSL https://getmic.ro | bash \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
USER dev
WORKDIR /home/dev
It builds. No problem. But then I have this panel image that uses my core image:
FROM nefcanto/core:latest
ENV PATH="${PATH}:/core/commands/panel:/core/commands"
RUN npm install --location=global serve -y
RUN echo DefaultLimitNOFILE=65536 > /etc/systemd/system.conf
RUN echo DefaultLimitNOFILE=65536 > /etc/systemd/user.conf
RUN ulimit -n 65536
It fails when I add RUN usermod -d /home/dev -l dev node line. This is the permission error:
#6 [2/5] RUN npm install --location=global serve -y
#6 3.422 npm error code EACCES
#6 3.423 npm error syscall mkdir
#6 3.423 npm error path /usr/local/lib/node_modules/serve
#6 3.423 npm error errno -13
#6 3.425 npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serve'
#6 3.425 npm error at async mkdir (node:internal/fs/promises:861:10)
#6 3.425 npm error at async /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:572:20
#6 3.425 npm error at async Promise.allSettled (index 0)
#6 3.425 npm error at async #reifyPackages (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:309:11)
#6 3.425 npm error at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:5)
#6 3.425 npm error at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
#6 3.425 npm error at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:208:9)
#6 3.425 npm error at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:67:5) {
#6 3.425 npm error errno: -13,
#6 3.425 npm error code: 'EACCES',
#6 3.425 npm error syscall: 'mkdir',
#6 3.425 npm error path: '/usr/local/lib/node_modules/serve'
#6 3.425 npm error }
#6 3.426 npm error
#6 3.426 npm error The operation was rejected by your operating system.
#6 3.426 npm error It is likely you do not have the permissions to access this f
When I run it as node user, both images are built. But when I change the username to dev it seems that the permissions are broken. Do you have any idea why?
In general, renaming the node user to dev will not inherently break Node.js itself. Linux processes care about the numeric UID/GID much more than the username. If the user remains UID 1000 and GID 1000, most software will continue to work exactly the same way.
If you're building on top of the official image, it's often simpler to leave the node user as-is and just use:
Note that the node user is neither a build-time nor a run-time dependency and it can be removed or altered, as long as the functionality of the application you want to add to the container does not depend on it.
Activity
avivkeller commentedon Dec 29, 2025
@nodejs/docker
nschonni commentedon Dec 29, 2025
https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user talks about changing the UID
Nefcanto commentedon Dec 30, 2025
@nschonni I read that part. I just want to change the name of the user. This is my
coreimage:It builds. No problem. But then I have this
panelimage that uses mycoreimage:It fails when I add
RUN usermod -d /home/dev -l dev nodeline. This is the permission error:When I run it as
nodeuser, both images are built. But when I change the username todevit seems that the permissions are broken. Do you have any idea why?LegendCo commentedon Jun 17, 2026
In general, renaming the node user to dev will not inherently break Node.js itself. Linux processes care about the numeric UID/GID much more than the username. If the user remains UID 1000 and GID 1000, most software will continue to work exactly the same way.
If you're building on top of the official image, it's often simpler to leave the node user as-is and just use:
USER nodeMikeMcC399 commentedon Aug 10, 2026
https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user in #5125 (comment) already provided the answer: