10

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?

1 Answer 1

13

Found out you can replace bash with the name of the shell you want to open, so in this case mongo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.