# Get username with dockerspawner

**URL:** https://discourse.jupyter.org/t/get-username-with-dockerspawner/24978
**Category:** JupyterHub
**Tags:** docker
**Created:** [April 4, 2024, 9:10am UTC](https://discourse.jupyter.org/t/get-username-with-dockerspawner/24978 "2024-04-04T09:10:56Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)
#### Post date: [April 4, 2024, 9:34am UTC](https://discourse.jupyter.org/t/get-username-with-dockerspawner/24978/2 "2024-04-04T09:34:00Z")

</div>

You can inject the `user` parameter directly into the spawner environment which will be eventually merged with [`extra_container-spec`](https://github.com/jupyterhub/dockerspawner/blob/2e89ca0c5d89dbedf2c42aad06a32c2daf0376fb/dockerspawner/swarmspawner.py#L191-L197). You can make `c.Spawner.environment` a callable to get `spawner.user.name` which corresponds to your moodle ID. Check this [topic](https://discourse.jupyter.org/t/set-environment-variables-based-on-user-for-example-use-home/24800) on how to do it.

---

_[View the full topic](https://discourse.jupyter.org/t/get-username-with-dockerspawner/24978)._
