# Docker-compose script with prompt.... better solution?

**URL:** <https://forums.docker.com/t/docker-compose-script-with-prompt-better-solution/48016>\
**Category:** Compose\
**Created:** [March 16, 2018, 3:48pm UTC](https://forums.docker.com/t/docker-compose-script-with-prompt-better-solution/48016 "2018-03-16T15:48:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pir81](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@pir81](https://forums.docker.com/u/pir81)\
**Post date:** [March 16, 2018, 3:48pm UTC](https://forums.docker.com/t/docker-compose-script-with-prompt-better-solution/48016/1 "2018-03-16T15:48:54Z")

</div>

Hi, I have a **bash script** to start various docker-compose.yml(s)

One of these compose instances is `docker-compose.password.yml` to create a password file for mysql. For that I need to prompt the user to input a user name and then run a service in docker (that is actually not running).

basically the only way I can think of to accomplish this is run the docker in idle state, exec the command and close the docker. Is there a better way?

XXXXXXXXXX  
My solution:

docker-compose.password.yml

```
version: '2'
services:
  createpw:
    command:
      top -b -d 3600

```

then

`docker-compose -f docker-compose.password.yml up -d`

prompt the user by my `bash script` outside of docker for the credentials  
`read -p "Input user name.`echo $’\n\> ’`" username`

and send it to the running docker

`docker exec createpw /bin/bash -c "mysql_config_editor set --user=${username} --password"`

and then `docker-compose down`

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
Tried and not working:  
I tried to have just a small subscript prompting for the input right under command

```
command:
  /bin/bash /somewhere/createpassword.sh

```

This did produce the file, but the user was an empty string, as the prompt didn’t stop the docker execution. It didn’t matter if I used compose -d or not.

Any suggestions are welcome. Thanks.
