Firt of all: I don't want to connect to a docker container, running mongo.
I am building a docker container that should access the mongo database I have installed in my running Ubuntu 18.04 machine.
Docker suggests this could be done fairly easy by just adding the flag -pto the run command, so I did this:
docker run -p 27017:27017 --name mycontainer myimage
Port 27017 is the default port for mongo (see here) and running netstat -pna | grep 27017 confirms by returning the following:
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:27017         127.0.0.1:55880         ESTABLISHED -                   
tcp        0      0 127.0.0.1:55882         127.0.0.1:27017         ESTABLISHED -                   
tcp        0      0 127.0.0.1:55880         127.0.0.1:27017         ESTABLISHED -                   
tcp        0      0 127.0.0.1:27017         127.0.0.1:55884         ESTABLISHED -                   
tcp        0      0 127.0.0.1:27017         127.0.0.1:55882         ESTABLISHED -                   
tcp        0      0 127.0.0.1:55884         127.0.0.1:27017         ESTABLISHED -                   
unix  2      [ ACC ]     STREAM     LISTENING     77163    -                    /tmp/mongodb-27017.sock
But running the docker command shown above, I get an error indicating that I can't connect to the port because it is already in use (which is actually the whole point of connecting to it):
docker: Error response from daemon: driver failed programming external connectivity on endpoint mycontainer (1c69e178b48ee51ab2765479e0ecf3eea8f43e6420e34b878882db8d8d5e07dd): Error starting userland proxy: listen tcp4 0.0.0.0:27017: bind: address already in use.
ERRO[0000] error waiting for container: context canceled 
How should I proceed? What did I do wrong?
 
     
    