# Docker Compose pre or post scripts after container start

**URL:** <https://forums.docker.com/t/docker-compose-pre-or-post-scripts-after-container-start/22615>\
**Category:** Compose\
**Created:** [September 26, 2016, 9:07pm UTC](https://forums.docker.com/t/docker-compose-pre-or-post-scripts-after-container-start/22615 "2016-09-26T21:07:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pchockalingam](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pchockalingam](https://forums.docker.com/u/pchockalingam)\
**Post date:** [September 26, 2016, 9:07pm UTC](https://forums.docker.com/t/docker-compose-pre-or-post-scripts-after-container-start/22615/1 "2016-09-26T21:07:56Z")

</div>

I searched the web and also docker compose file reference for a way to run a script(s) prior to a container build. I need this so I can update my docker build directory with latest artifacts for a service.I have a use case to run some post update script(s) to update the container after it was run as well. I currently can do all of this with bash wrapper scripts with docker commands. Wondering whether I can use docker-compose to do a pre/post script runs without resorting to wrapper bash shell type situation.

Environment:  
docker-compose version: 1.7.1  
docker version 1.12.0  
OS: CentOS Linux release 7.2.1511

Please let me know if there are options or other approaches to do accomplish this. Thanks

---

<div class="post-metadata">

**Author:** ![dmaze](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@dmaze](https://forums.docker.com/u/dmaze)\
**Post date:** [September 27, 2016, 2:24am UTC](https://forums.docker.com/t/docker-compose-pre-or-post-scripts-after-container-start/22615/2 "2016-09-27T02:24:17Z")

</div>

> [@pchockalingam](#):
>
> I searched the web and also docker compose file reference for a way to run a script(s) prior to a container build. I need this so I can update my docker build directory with latest artifacts for a service.

I’m not aware of a general convention or standard tooling for this. My `Dockerfile`s tend to have a `setup.sh` script alongside them.

> [@](#):
>
> I have a use case to run some post update script(s) to update the container after it was run as well.

The `ENTRYPOINT` script in a `Dockerfile` gets run whenever the container is started.

---

<div class="post-metadata">

**Author:** ![pchockalingam](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pchockalingam](https://forums.docker.com/u/pchockalingam)\
**Post date:** [September 27, 2016, 9:04pm UTC](https://forums.docker.com/t/docker-compose-pre-or-post-scripts-after-container-start/22615/3 "2016-09-27T21:04:25Z")

</div>

Thank you David. I am trying to run an Oracle container.

> **[oracle/docker-images](https://github.com/oracle/docker-images/tree/master/OracleDatabase)**
>
> docker-images - Official source for Docker configurations, images, and examples of Dockerfiles for Oracle products and projects

One of the steps is to change the default password and also I want to import a local database - all part of the run or docker-compose up -d.

Oracle has to be instantiated prior to a user logging and changing the sys passwords. My question is whether there are any mechanisms to do this in docker-compose like a hook after the container has started.

In the above example, the CMD calls ‘[runOracle.sh](http://runOracle.sh)’. I want to:

- change the default passwords (run [setPasswords.sh](http://setPasswords.sh))
- load a db (some load bash script…)

I can do the above using ‘docker exec’ easily and it works but it would be nice if I can integrate that as part of docker-compose or even docker build (via Dockerfile or scripts during run) and not as a separate script if possible.

I don’t know whether I am making it clear.

Thx.
