Create Mongo docker image and add user to database

0 votes

I'm attempting to figure out how to make a docker container that automatically creates the database user profile. I'm using a Dockerfile and figured I could include the commands for creating the user there.

Does anyone know how to do this? I am still a beginner in docker so any help would be much appreciated.

FROM mongo:latest

RUN mongo &&\
    use tewtdb &&\
    db.createUser({user: '<user>', pwd: '<pwrd>', roles[{role: 'dbOwner', db: 'tewtdb'}]})

EXPOSE 27017

CMD ["mongod"]

Apr 20 in Docker by pranav
• 2,580 points
498 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Docker

0 votes
1 answer

How to create docker file and docker image?

You will have to create a dockerfile ...READ MORE

answered Oct 24, 2020 in Docker by Sam
276 views
0 votes
1 answer

How to create a container and run images in docker?

Look for what all images you have ...READ MORE

answered Feb 23, 2019 in Docker by Kalgi
• 52,350 points
1,092 views
0 votes
1 answer
0 votes
1 answer

How to create a user-defined Bridge network in docker?

To create a user-defined bridge network, one ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,190 points
1,883 views
+2 votes
1 answer

Not able to create docker robot framework image

Did your try FROM Python3 READ MORE

answered Aug 21, 2020 in Docker by anonymous
1,288 views
+2 votes
0 answers

trying to create a service to multiple nodes and getting "no such image"

How come this has come up as ...READ MORE

Feb 2, 2020 in Docker by Karenh
• 200 points
1,556 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,100 points
1,853 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP