Start-up service not working inside LXD

I’ve build a container installed Jupyter Lab and OneDrive mouting point. However, during boot or restart, the services doesn’t start.

ubuntu@jupyter:~$ sudo service jupyter status
● jupyter.service - Jupyter Lab
   Loaded: loaded (/etc/systemd/system/jupyter.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
ubuntu@jupyter:~$ sudo service onedrive status
● onedrive.service - OneDrive (rclone)
   Loaded: loaded (/etc/systemd/system/onedrive.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

If I manually restart, they work. Am I missing something?

What does systemctl --failed show after boot?

There’s most likely some kind of dependency going on between units which isn’t properly resolved at boot, leading to the services not starting.

ubuntu@jupyter:~$ sudo systemctl --failed --all
  UNIT                         LOAD   ACTIVE SUB    DESCRIPTION                                                                                                                   
● home-ubuntu-NextCloud.mount  loaded failed failed /home/ubuntu/NextCloud                                                                                                        
● systemd-modules-load.service loaded failed failed Load Kernel Modules                                                                                                           

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

2 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.

Nextcloud is a wabdav mount, however I have no idea what are these modules.

ubuntu@jupyter:~$ sudo service systemd-modules-load status
● systemd-modules-load.service - Load Kernel Modules
   Loaded: loaded (/lib/systemd/system/systemd-modules-load.service; static; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-10-29 15:35:22 UTC; 3min 20s ago
     Docs: man:systemd-modules-load.service(8)
           man:modules-load.d(5)
  Process: 73 ExecStart=/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE)
 Main PID: 73 (code=exited, status=1/FAILURE)

Oct 29 15:35:22 jupyter systemd[1]: systemd-modules-load.service: Main process exited, code=exited, status=1/FAILURE
Oct 29 15:35:22 jupyter systemd[1]: systemd-modules-load.service: Failed with result 'exit-code'.
Oct 29 15:35:22 jupyter systemd[1]: Failed to start Load Kernel Modules.
ubuntu@jupyter:~$ sudo journalctl _PID=73
-- Logs begin at Thu 2019-10-24 16:30:23 UTC, end at Tue 2019-10-29 15:40:21 UTC. --
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '4 4 1 7' to 'kernel/printk', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '1' to 'kernel/kptr_restrict', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '1' to 'fs/protected_hardlinks', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '1' to 'fs/protected_symlinks', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '1024' to 'fs/inotify/max_user_instances', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '176' to 'kernel/sysrq', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '1' to 'net/ipv4/tcp_syncookies', ignoring: No such file or directory
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '1' to 'kernel/yama/ptrace_scope', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write '65536' to 'vm/mmap_min_addr', ignoring: Permission denied
Oct 29 02:06:30 jupyter systemd-sysctl[73]: Couldn't write 'fq_codel' to 'net/core/default_qdisc', ignoring: No such file or directory
Oct 29 15:35:22 jupyter systemd-modules-load[73]: could not open moddep file '/lib/modules/4.4.0-166-generic/modules.dep.bin'
Oct 29 15:35:22 jupyter systemd-modules-load[73]: Failed to lookup alias 'iscsi_tcp': Function not implemented
Oct 29 15:35:22 jupyter systemd-modules-load[73]: could not open moddep file '/lib/modules/4.4.0-166-generic/modules.dep.bin'
Oct 29 15:35:22 jupyter systemd-modules-load[73]: Failed to lookup alias 'ib_iser': Function not implemented
$ sudo depmod
depmod: ERROR: could not open directory /lib/modules/4.4.0-166-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory

I’m really lost if this is a problem since modules are shared from host machine. There is some other problem. Any help, please?

from Reading The Fine Manual (man systemd-modules-load, man modules-load.d) it seems you should ensure that /etc/modules.d does not contain any module reference since a proper container (that is, unprivileged) can not load modules (and with such software you are trying to install you should definitely not run them privileged).
Then after removing these modules from the container configuration, add these modules to your host’'s kernel by any mean necessary (I seem to recall that lxd has a feature to load automatically some modules when a container starts, there is some reading here)

I just found that my machine doesn’t start modules but this is not my main problem.

In fact, I don’t need them. My container is running fine.

I’ve used also the suggestion:

lxc config set mycontainer linux.kernel_modules [module]

I need, however, to understand why my other services are not stating during boot since they are enable.

I dig a bit and I think that these modules don’t have correlation with onedrive and jupyter service. I mean, the boot process should not stop if it founds a problem with other services, right?

In your place I’d use lxc console to see what happens at startup. It’s even possible that your container is not starting propertly. Most distro finish the startup cleanly and you get a login if you use lxc console and hit Enter.
It it does not work, it may be an indication that your container is not initializing completely; in this case lxc console --show-log can help (warning, --show-log works only one time, if you lose this info you have to restart the container)

Hiya!

Could you please provide the following information?

  1. What instructions do you use to install the JupyterLab?
  2. Which OneDrive software do you use? There is a paid one, and another open-source one.
  3. Can you setup in a container only one of the two, in order to figure out which is not able to start when the container is restarted? This will help to pinpoint whether only one of the two is the culprit.