i believe my below successed experience is helpful for solving you problem and others who stuck on similar problem with other jupyter notebooks image.
Be not professional coder and i just study QNAP NAS for fun with Jupyterlab.
it did cost one and half day on studying internet, including stackoverflow and github. But some coder's informations are too professional for me to fully understand and implement. Finally, based on those hints and with Doubao AI support, i made it success.
Below are very detail records on the way.
https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html is too simple and for non-professional guys like me has very little helpful info.
============================
QNAP NAS using the scipy-notebook image jovyan cannot install or run programs using sudo.
========
when create containers in QNAP contatiner station
Add environment to containerstation:
-e RESTARTABLE=yes - Recycles Jupyter so that exiting Jupyter does not cause the container to exit. This may be useful when installing extensions that require restarting Jupyter.
-e GRANT_SUDO=yes - Grants access to sudo commands.
Add storage to containerstation:
your_workdocs_folder: /home/jovya. /home/jovya is the location where new notebooks are saved within the container and should be mapped to avoid loss during Docker changes.
======
pls open ssh in your QNAP NAS server and use putty(or other you are famliar with) sign in with admin users.
if you are not familiar with tools, cmds, pls use any AI to support. not complicate.
** DONT forget to close the ssh port after done , especially your server are in internet **
then follow below steps.
# Replace my own container scipy-notebook-202508 with the name of the container started in your own Docker container.
# Create a container started by the root user, configure the Ubuntu system in the container, and grant sudo permissions to the jovyan account.
[{QNAP ssh administrator} bin]$ docker exec -it -u root scipy-notebook-202508 /bin/bash
# Use apt-get to reinstall the sudo and vim tools required.
# Sometimes, a message appears indicating that vim cannot be used by the root user, although files can still be opened. To be on the safe side, it is recommended to reinstall.
root@a3557768d332:~# apt-get update
root@a3557768d332:~# apt-get install -y sudo
root@a3557768d332:~# apt update && apt reinstall -y vim
# You can directly modify visudo, but this is the recommended method. It's more convenient for deleting or adding new configurations later and won't corrupt the main sudoers file.
# I've confirmed that the /sudoers.d folder is included at the end of the main file. jovyan_config is the new configuration I created.
# The file contains only one line: jovyan ALL=(ALL:ALL) ALL. After adding ALL, press Escape, enter :wq to save, and exit.
root@a3557768d332:~# visudo -f /etc/sudoers.d/jovyan_config
# Change jovyan's password; I don't know the original password. It's recommended to set a more complex setting, including uppercase and lowercase special characters, and to use more than 10 characters.
# After all, 1. jovyan has root privileges, and 2. it can be accessed from the public network, not the Docker Hub, so there's no multi-person permission management.
root@a3557768d332:~# sudo passwd user2
Enter new UNIX password: [Enter new password]
Retype new UNIX password: [Enter new password again]
passwd: password updated successfully
# Exit scipy-notebook started by the root user
root@a3557768d332:~# exit
# Restart docker scipy-notebook-202508
# Check your running Docker, operating under the QNAP SSH administrator account.
[{QNAP SSH Administrator} bin]$ docker ps
[{QNAP SSH Administrator} bin]$ docker restart {your container name}
# ===Re-login in the JupyterLab interface. try sudo xxxx, enter jovyan's password, works ======
The following is from the JupyterLab terminal:
jovyan@a3557768d332:~$ sudo apt-get install -y cron
[sudo] password for jovyan:
Sorry, try again.
[sudo] password for jovyan:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
cron is already the newest version (3.0pl1-137ubuntu3).
0 upgraded, 0 newly installed, 0 to remove, and 113 not upgraded.
jovyan@a3557768d332:~$