nodejs / nodejs/docker-node

Add --no-log-init to the node user that gets created to avoid massive image sizes

Open Beginner friendly
#1,779 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dockerfile
Stars
8.6k
Forks
2k
Avg merge
10h 19m
Merged PRs (30d)
16

Description

Problem

Currently the node user is created with useradd --uid 1000 --gid node --shell /bin/bash --create-home node.

When customizing the UID / GID using build args with groupmod -g "${GID}" node && usermod -u "${UID}" -g "${GID}" node, some folks are reporting they are running out of disk space and can't build the image when they have a non-1000 UID on systems that create a lot of users.

Here's a comment going into more detail: https://github.com/nickjj/docker-flask-example/pull/7#issuecomment-1266698181

Also not using --no-log-init will cause Hadolint to throw this warning: -:44 DL3046 warning: useradd without flag -l and high UID will result in excessively large Image.

The usermod command doesn't support being able to set that option so it means our only option is to delete the node user and create a new one in which case life could be simplified by setting that flag here. You could make a case this is a bug report and not feature request due to the implications of not setting this flag when you create users in a Docker image.

Solution

Add --no-log-init to all of the useradd commands that create the node user.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the Docker image build definitions for every useradd command that creates the node user, starting with the command shown in the issue. Add the requested option to each applicable command, then build the affected images and check that the reported Hadolint warning is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, dockerfile
Domain
build-system, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.