# How to specify a js to be executed once (e.g. /docker-entrypoint-initdb.d/init.js)

**URL:** https://forums.percona.com/t/how-to-specify-a-js-to-be-executed-once-e-g-docker-entrypoint-initdb-d-init-js/39681
**Category:** Percona Operator for MongoDB
**Created:** [November 4, 2025, 2:09pm UTC](https://forums.percona.com/t/how-to-specify-a-js-to-be-executed-once-e-g-docker-entrypoint-initdb-d-init-js/39681 "2025-11-04T14:09:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![r.gambelli](https://avatars.discourse-cdn.com/v4/letter/r/a87d85/32.png) [@r.gambelli](https://forums.percona.com/u/r.gambelli)
#### Post date: [November 4, 2025, 2:09pm UTC](https://forums.percona.com/t/how-to-specify-a-js-to-be-executed-once-e-g-docker-entrypoint-initdb-d-init-js/39681/1 "2025-11-04T14:09:04Z")

</div>

Hi all,

I’m testing Pecona mongodb installed via operator in a k8s environment.

I would like to know if it’s possible and how to do it, set a script to be executed only one time when volume is created at its first time.

In docker-compose I do in this way:

`volumes:`  
`- type: bind`  
`source: ${BASE_DOCKER}/db-init/mongodb/init.js`  
`target: /docker-entrypoint-initdb.d/init.js`  
`- mongodb_data:/data/db`

Thanks in advance

---

<div class="post-metadata">

### Author: ![radoslaw.szulgo](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/radoslaw.szulgo/32/17315_2.png) [@radoslaw.szulgo](https://forums.percona.com/u/radoslaw.szulgo)
#### Post date: [November 5, 2025, 10:48am UTC](https://forums.percona.com/t/how-to-specify-a-js-to-be-executed-once-e-g-docker-entrypoint-initdb-d-init-js/39681/2 "2025-11-05T10:48:03Z")

</div>

Hi @r.gambelli and welcome to our community!

Unfortunately, in Percona Operator for MongoDB, you **cannot** replicate the `docker-compose` `volumes` mount in the same way. However, you can achieve the same result with an additional Kubernetes job.

1. Store the script in a ConfigMap:  
`kubectl create configmap my-mongo-init-script --from-file=init.js`

2. Create a Job that will spin up a pod, mount the `ConfigMap`, and use the `mongo` shell to connect to your new cluster and execute the script.

Or something similar 🙂 Hope that helps to start. Alternatively, you could build your custom dockerimage based on Percona’s official ones - but that might be tricky to maintain that.
