I want to create a bash script that removes a user from a mongodb database that is running inside a docker container.
Normally through the terminal I would execute docker exec -it mycontainername bash
and then once I'm in the container I execute mongo mydbname --eval "db.users.remove({"firstname":"Bob"})"
I just have no idea how to do it in a linux bash script.
After I execute script that contains the docker exec
command, it leaves the script and opens the docker container's terminal and prompts me to enter a command.
Would using the detached -d
flag work?
Found out you can replace bash
with the name of the shell you want to open, so in this case mongo
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With