openml / automlbenchmark

OpenML AutoML Benchmarking Framework
https://openml.github.io/automlbenchmark
MIT License
391 stars 130 forks source link

Revise docker permission setup #545

Open PGijsbers opened 1 year ago

PGijsbers commented 1 year ago

495 introduced an issue when building public images: the image is set up for the builder, but the user will start the container under a different uid, which leads to permission errors. I think we should remove any user information from the docker container, and instead create/assign permissions on startup with something like:

set -e

if [ $UID = 0 ]; then
  echo "Docker started as root, not changing file permissions."
  exit 0
fi

user_id=$UID
echo "root" | su -c "adduser --disabled-password --gecos '' -uid $user_id amlb"
echo "root" | su -c "echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"
echo "root" | su -c "chown -R amlb:amlb /home/amlb"
echo "root" | su -c "chown -R amlb:amlb /bench"
echo "root" | su -c "passwd -d amlb"
su "amlb"

And then invoking above script before running python runbenchmark.py. This way the permissions are set for the person running the docker container, not the one building the image.

Originally posted by @PGijsbers in https://github.com/openml/automlbenchmark/issues/495#issuecomment-1598703676