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

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.