Reputation: 10122
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?
Upvotes: 10
Views: 7165
Reputation: 10122
Found out you can replace bash
with the name of the shell you want to open, so in this case mongo
.
Upvotes: 13