1

I have a new Azure VM (Ubuntu 18.04.1 LTS) which has docker.

dragam@USDockerVM:~$ IRE> docker --version
Docker version 18.09.0, build 4d60db4

Issued the command

docker pull mongo

this ran without issue.

Then I ran

docker run --name tom-mongo -d mongo:latest

also tried

docker run --name some-mongo -v /home/dragam/data:/data/db -d mongo

to run a mongod with a database named tom-mongo (and tried to specify the data directory if that would help?)

and then I ran (again in the VM - commands from here)

docker run -it --link tom-mongo:mongo --rm mongo mongo --host mongo test

to start a mongodb client on the VM - works. I can use the client to connect and access the data as follows:

> use local
switched to db local
> show collections
startup_log
> db.startup_log.find().pretty()
produces 1 record with server startup details - time &c... no problems

docker ps gives:

dragam@USDockerVM:/$ IRE> docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
33c58af3862e        mongo               "docker-entrypoint.s…"   2 minutes ago       Up 2 minutes        27017/tcp           agitated_hypatia
c39d4ceff690        mongo:latest        "docker-entrypoint.s…"   41 minutes ago      Up 41 minutes       27017/tcp           tom-mongo

and ps -ef | grep mongo gives:

dragam@USDockerVM:/$ IRE> ps -ef | grep mongo
999      13490 13469  0 12:42 ?        00:00:05 mongod --bind_ip_all
dragam   17466 13242  0 13:20 pts/1    00:00:00 docker run -it --link tom-mongo:mongo --rm mongo mongo --host mongo test
999      17535 17513  0 13:20 pts/0    00:00:00 mongo --host mongo test
dragam   18021  2487  0 13:24 pts/0    00:00:00 grep --color=auto mongo

The output of iptables -L (shown at the end of the question) appears to have no problems with blocking ports - I have used this VM for other docker container systems and connected without problems.

Now, my question is - How do I connect to my Azure instance of MongoDB from a bash shell on my local machine? I have setup my public ssh key on the Azure instance and can login no problem without a password using bash.

Do I need to setup a password for mongodb on the VM? I have tried various strings like:

mongo mongodb://mongo:mongo@host:xxx.yyy.zzz.aaa/tom-mongo?ssl=true

and even simple ones like

mongo xxx.yyy.zzz.aaa/tom-mongo

Is there a default mongodb container username and password combination? Is there something obvious that I am missing?

Should I have set up the instance differently? Have I a proper username and password with this setup?

Should I be taking a completely different approach? This is for a College Proof of Concept project - security is not an issue!

(originally posted here - have indicated that this is now the definitive question.

==== output of lsb_release -a =========

dragam@USDockerVM:~$ IRE> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic
dragam@USDockerVM:~$ IRE> 

========= Output of sudo iptables -L ==========

dragam@USDockerVM:/$ IRE> sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy DROP)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain DOCKER (1 references)
target     prot opt source               destination         

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination         
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            
dragam@USDockerVM:/$ IRE>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.