Spawner.init_containers not working

Hello,
Then below pre_spawner_hook doesn’t work. Would anyone have any idea?

hub:
  extraConfig:
    pre_spawn_hook: |
        async def pre_spawn_hook(spawner):
          
          user_options = spawner.user_options
            if user_options['profile'] == 'something':
              spawner.init_containers = [{
                "name":"xxxx",
                "image": "busybox",
                "command": ["sh","-c","mkdir -p /etc/jupyter/xxx"]
              }]

It seems like the busybox is pulled but the directory is not created.
best

You might want to look up more about the relationships between init containers, filesystems, and volumes. Your example modifies files in the init container only because the modifications are not in a persisted volume. If you want to populate files in an init contianer that affect the notebook container, you’ll need to do so in a volume mounted by both containers.

1 Like