Mount Permissions

The Lightly Worker needs the following permissions for the mounted directories:

  • Input mount: read and conditional execute permissions (rX)
  • Lightly mount: read, write, and execute permissions (rwx)

The easiest way to give access permissions for the Lightly Worker is to run this command on the input and Lightly mount directories:

chmod -R a+rX /home/user/project_xyz/input
chmod -R a+rwx /home/user/project_xyz/lightly

Custom User and Group

If the mount directories on the host have strict access permissions, for example when using a network drive, it can happen that the files are not accessible to the Lightly Worker. In that case, you can run the Lightly Worker with a specific user and group by setting the LIGHTLY_UID and LIGHTLY_GID environment variables when starting the docker container:

docker run --shm-size "1024m" --gpus all --rm -it \
  -v /home/user/project_xyz/input:/input_mount:ro \
  -v /home/user/project_xyz/lightly:/lightly_mount \
  -e LIGHTLY_TOKEN={MY_LIGHTLY_TOKEN} \
  -e LIGHTLY_WORKER_ID={MY_WORKER_ID} \
  -e LIGHTLY_UID={MY_USER_ID} \						
  -e LIGHTLY_GID={MY_GROUP_ID} \
  lightly/worker:latest

The Lightly Worker runs by default with user id 1000 and group id 1000. On startup, the worker will change ownership of the Lightly mount directory and all its files to the Lightly Worker user. All files created by the Lightly Worker will also be owned by the Lightly Worker user.

The LIGHTLY_UID must be set to the user id of the owner of the Lightly mount directory. This user must have read, write, and execute permissions for the Lightly mount directory. You can find the user id with stat -c '%u' /home/user/project_xyz/lightly.

If the input and Lightly mounts are owned by the same user, it is sufficient to only set the LIGHTLY_UID and omit LIGHTLY_GID. However, if the user with id LIGHTLY_UID cannot access the input mount directory, you have to set LIGHTLY_GID to the group id of the input mount directory. This group must have read and execute (for directories) permissions for the input mount directory. You can find the group id with stat -c '%g' /home/user/project_xyz/lightly.

The following command automatically starts the Lightly Worker with the correct user and group ids:

docker run --shm-size "1024m" --gpus all --rm -it \
  -v /home/user/project_xyz/input:/input_mount:ro \
  -v /home/user/project_xyz/lightly:/lightly_mount \
  -e LIGHTLY_TOKEN={MY_LIGHTLY_TOKEN} \
  -e LIGHTLY_WORKER_ID={MY_WORKER_ID} \
  -e LIGHTLY_UID=$(stat -c '%u' /home/user/project_xyz/lightly) \						
  -e LIGHTLY_GID=$(stat -c '%g' /home/user/project_xyz/lightly) \
  lightly/worker:latest

Please see our FAQ if you encounter permission issues.