Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: entrypoint fails if group exists #606

Closed
KrisThielemans opened this issue Jun 28, 2021 · 7 comments · Fixed by #607
Closed

docker: entrypoint fails if group exists #606

KrisThielemans opened this issue Jun 28, 2021 · 7 comments · Fixed by #607
Assignees
Labels

Comments

@KrisThielemans
Copy link
Member

Found by @mastergari

./sirf-compose tries to find the group of the current user, and create a group in the docker image accordingly. However, when that group already exists, subsequent adduser fails:

“Creating sirfuser:501:20
addgroup: The GID `20' is already in use.
adduser: The group `sirfuser' does not exist.
addgroup: The user `sirfuser' does not exist.
Updating file ownership for /home/sirfuser
chown: invalid user: ‘sirfuser:sirfuser’
Switching to sirfuser and executing /usr/local/bin/service.sh
error: failed switching to "sirfuser": unable to find user sirfuser: no matching entries in passwd file”
@KrisThielemans KrisThielemans self-assigned this Jun 28, 2021
@KrisThielemans
Copy link
Member Author

The problem is in the following lines

addgroup --quiet --system --gid "$GROUP_ID" "$mainUser"
# useradd --shell /bin/bash -u $USER_ID -o -c "" -M -d $HOME \
# -g $mainUser -G sudo $mainUser \
# -p $(echo somepassword | openssl passwd -1 -stdin)
adduser --quiet --system --shell /bin/bash \
--no-create-home --home /home/"$mainUser" \
--ingroup "$mainUser" --uid "$USER_ID" "$mainUser"

The adduser command should use the --gid option as opposed to --ingroup, as the groupname would have failed.

@KrisThielemans
Copy link
Member Author

KrisThielemans commented Jun 28, 2021

A possibly work-around for an existing image could be to edit sirf-compose and say

cd "$(dirname $0)"
export GROUP_ID=10000 # some non-existent group  number
export USER_ID=$(id -u)
docker-compose -f docker-compose.yml -f docker-compose.nix.yml "$@"

or equivalently edit

GROUP_ID: ${GROUP_ID:-1000}

to

  GROUP_ID: 10000

KrisThielemans added a commit to KrisThielemans/SIRF-SuperBuild that referenced this issue Jun 28, 2021
The entrypoint.sh failed if `GROUP_ID` refers to an existing group,
as the `adduser` command referred to it via the wrong name.

Fixes SyneRBI#606
KrisThielemans added a commit to KrisThielemans/SIRF-SuperBuild that referenced this issue Jun 28, 2021
The entrypoint.sh failed if `GROUP_ID` refers to an existing group,
as the `adduser` command referred to it via the wrong name.

Fixes SyneRBI#606

[actions skip]
@KrisThielemans
Copy link
Member Author

Better would be to pull the PR:

cd /wherever/SIRF-SuperBuild/docker
git remote add kris-fork git@github.com:KrisThielemans/SIRF-SuperBuild.git
git fetch kris-fork
git checkout docker_group_fix
./sirf-compose-server down 
./sirf-compose-server build sirf
docker image prune # get rid of previous image
./sirf-compose-server up -d sirf

@KrisThielemans
Copy link
Member Author

@mastergari let us know if you try either of those.

@KrisThielemans
Copy link
Member Author

This works for me, but of course I never had the problem.

@mastergari
Copy link

@KrisThielemans I am able to access localhost:9999 after editing sirf-comopose with your above commands. I was unable to pull the PR which failed at "git fetch kris-fork" due to insufficient access rights:

  Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts.
  git@github.com: Permission denied (publickey).
  fatal: Could not read from remote repository.
  
  Please make sure you have the correct access rights
  and the repository exists.

I had no problems setting up docker on my linux machine. Thank you for the assistance!

@KrisThielemans
Copy link
Member Author

oops.

git remote add kris-fork https://github.com/KrisThielemans/SIRF-SuperBuild.git

Anyway. We'll probably merge this tomorrow. Thanks for letting us know!

KrisThielemans added a commit that referenced this issue Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants