title: Access mongo shell running in docker container in linux script
body: <p>I want to create a bash script that removes a user from a mongodb database that is running inside a docker container.</p>
  
  <p>Normally through the terminal I would execute <code>docker exec -it mycontainername bash</code> </p>
  
  <p>and then once I'm in the container I execute <code>mongo mydbname --eval "db.users.remove({"firstname":"Bob"})"</code></p>
  
  <p>I just have no idea how to do it in a linux bash script.</p>
  
  <p>After I execute script that contains the <code>docker exec</code> command, it leaves the script and opens the docker container's terminal and prompts me to enter a command. </p>
  
  <p>Would using the detached <code>-d</code> flag work?</p>