# Spawner.init\_containers not working

**URL:** https://discourse.jupyter.org/t/spawner-init-containers-not-working/23500
**Category:** Zero to JupyterHub on Kubernetes
**Tags:** jupyterhub
**Created:** [January 18, 2024, 11:02pm UTC](https://discourse.jupyter.org/t/spawner-init-containers-not-working/23500 "2024-01-18T23:02:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bpfrd](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bpfrd/32/10762_2.png) [@bpfrd](https://discourse.jupyter.org/u/bpfrd)
#### Post date: [January 18, 2024, 11:02pm UTC](https://discourse.jupyter.org/t/spawner-init-containers-not-working/23500/1 "2024-01-18T23:02:37Z")

</div>

Hello,  
Then below pre\_spawner\_hook doesn’t work. Would anyone have any idea?

```auto
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

---

<div class="post-metadata">

### Author: ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)
#### Post date: [January 19, 2024, 9:45am UTC](https://discourse.jupyter.org/t/spawner-init-containers-not-working/23500/2 "2024-01-19T09:45:40Z")

</div>

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.
