Mongo docker image - unable to run on different port












-1















There are a tons of question here on SO citing how this command alone



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo


should run mongo on port 27117.
However this doesn't work for me. The container runs, but the mongo is run on its default port alone (see output from container itself):



# mongo
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017

# mongo --port 27117
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27117/
2018-11-20T17:26:09.345+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27117, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27117 :: caused by :: Connection refused :


What is going on?



Thanks a lot!










share|improve this question























  • Could it be fire wall issue?

    – kosa
    Nov 20 '18 at 17:30











  • i'm trying from within the docker container, so no firewall there (i think)

    – JoeSlav
    Nov 20 '18 at 17:33
















-1















There are a tons of question here on SO citing how this command alone



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo


should run mongo on port 27117.
However this doesn't work for me. The container runs, but the mongo is run on its default port alone (see output from container itself):



# mongo
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017

# mongo --port 27117
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27117/
2018-11-20T17:26:09.345+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27117, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27117 :: caused by :: Connection refused :


What is going on?



Thanks a lot!










share|improve this question























  • Could it be fire wall issue?

    – kosa
    Nov 20 '18 at 17:30











  • i'm trying from within the docker container, so no firewall there (i think)

    – JoeSlav
    Nov 20 '18 at 17:33














-1












-1








-1








There are a tons of question here on SO citing how this command alone



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo


should run mongo on port 27117.
However this doesn't work for me. The container runs, but the mongo is run on its default port alone (see output from container itself):



# mongo
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017

# mongo --port 27117
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27117/
2018-11-20T17:26:09.345+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27117, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27117 :: caused by :: Connection refused :


What is going on?



Thanks a lot!










share|improve this question














There are a tons of question here on SO citing how this command alone



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo


should run mongo on port 27117.
However this doesn't work for me. The container runs, but the mongo is run on its default port alone (see output from container itself):



# mongo
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017

# mongo --port 27117
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27117/
2018-11-20T17:26:09.345+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27117, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27117 :: caused by :: Connection refused :


What is going on?



Thanks a lot!







mongodb docker






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 17:26









JoeSlavJoeSlav

1,71522240




1,71522240













  • Could it be fire wall issue?

    – kosa
    Nov 20 '18 at 17:30











  • i'm trying from within the docker container, so no firewall there (i think)

    – JoeSlav
    Nov 20 '18 at 17:33



















  • Could it be fire wall issue?

    – kosa
    Nov 20 '18 at 17:30











  • i'm trying from within the docker container, so no firewall there (i think)

    – JoeSlav
    Nov 20 '18 at 17:33

















Could it be fire wall issue?

– kosa
Nov 20 '18 at 17:30





Could it be fire wall issue?

– kosa
Nov 20 '18 at 17:30













i'm trying from within the docker container, so no firewall there (i think)

– JoeSlav
Nov 20 '18 at 17:33





i'm trying from within the docker container, so no firewall there (i think)

– JoeSlav
Nov 20 '18 at 17:33












2 Answers
2






active

oldest

votes


















2














With that command you are telling docker that the port is 27117, but you also need to start mongo with that port.



To do so, just add --port 27117 at the end of your command:



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo --port 27117





share|improve this answer
























  • Thank you worked.

    – JoeSlav
    Nov 20 '18 at 18:13



















2














Inside your container mongo runs on its default port, which is 27017



So, you should modify your command and specify the port mapping like this: -p 27117:27017



The full command would be this:



docker run --name mymongo --network bridge -p 27117:27017 -v "$PWD/db":/data/db  -d mongo





share|improve this answer
























  • Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

    – JoeSlav
    Nov 20 '18 at 18:14











  • You're welcome. I'm glad it helped. :-)

    – Ciprian Stoica
    Nov 20 '18 at 18:15











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398370%2fmongo-docker-image-unable-to-run-on-different-port%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














With that command you are telling docker that the port is 27117, but you also need to start mongo with that port.



To do so, just add --port 27117 at the end of your command:



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo --port 27117





share|improve this answer
























  • Thank you worked.

    – JoeSlav
    Nov 20 '18 at 18:13
















2














With that command you are telling docker that the port is 27117, but you also need to start mongo with that port.



To do so, just add --port 27117 at the end of your command:



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo --port 27117





share|improve this answer
























  • Thank you worked.

    – JoeSlav
    Nov 20 '18 at 18:13














2












2








2







With that command you are telling docker that the port is 27117, but you also need to start mongo with that port.



To do so, just add --port 27117 at the end of your command:



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo --port 27117





share|improve this answer













With that command you are telling docker that the port is 27117, but you also need to start mongo with that port.



To do so, just add --port 27117 at the end of your command:



docker run --name mymongo --network bridge -p 27117:27117 -v "$PWD/db":/data/db  -d mongo --port 27117






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 17:59









Julio Daniel ReyesJulio Daniel Reyes

2,082815




2,082815













  • Thank you worked.

    – JoeSlav
    Nov 20 '18 at 18:13



















  • Thank you worked.

    – JoeSlav
    Nov 20 '18 at 18:13

















Thank you worked.

– JoeSlav
Nov 20 '18 at 18:13





Thank you worked.

– JoeSlav
Nov 20 '18 at 18:13













2














Inside your container mongo runs on its default port, which is 27017



So, you should modify your command and specify the port mapping like this: -p 27117:27017



The full command would be this:



docker run --name mymongo --network bridge -p 27117:27017 -v "$PWD/db":/data/db  -d mongo





share|improve this answer
























  • Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

    – JoeSlav
    Nov 20 '18 at 18:14











  • You're welcome. I'm glad it helped. :-)

    – Ciprian Stoica
    Nov 20 '18 at 18:15
















2














Inside your container mongo runs on its default port, which is 27017



So, you should modify your command and specify the port mapping like this: -p 27117:27017



The full command would be this:



docker run --name mymongo --network bridge -p 27117:27017 -v "$PWD/db":/data/db  -d mongo





share|improve this answer
























  • Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

    – JoeSlav
    Nov 20 '18 at 18:14











  • You're welcome. I'm glad it helped. :-)

    – Ciprian Stoica
    Nov 20 '18 at 18:15














2












2








2







Inside your container mongo runs on its default port, which is 27017



So, you should modify your command and specify the port mapping like this: -p 27117:27017



The full command would be this:



docker run --name mymongo --network bridge -p 27117:27017 -v "$PWD/db":/data/db  -d mongo





share|improve this answer













Inside your container mongo runs on its default port, which is 27017



So, you should modify your command and specify the port mapping like this: -p 27117:27017



The full command would be this:



docker run --name mymongo --network bridge -p 27117:27017 -v "$PWD/db":/data/db  -d mongo






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 18:05









Ciprian StoicaCiprian Stoica

1,11611219




1,11611219













  • Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

    – JoeSlav
    Nov 20 '18 at 18:14











  • You're welcome. I'm glad it helped. :-)

    – Ciprian Stoica
    Nov 20 '18 at 18:15



















  • Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

    – JoeSlav
    Nov 20 '18 at 18:14











  • You're welcome. I'm glad it helped. :-)

    – Ciprian Stoica
    Nov 20 '18 at 18:15

















Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

– JoeSlav
Nov 20 '18 at 18:14





Thank you. I thought the port:port was a range of ports to be opened, and not a port mapping :) always learn something!

– JoeSlav
Nov 20 '18 at 18:14













You're welcome. I'm glad it helped. :-)

– Ciprian Stoica
Nov 20 '18 at 18:15





You're welcome. I'm glad it helped. :-)

– Ciprian Stoica
Nov 20 '18 at 18:15


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398370%2fmongo-docker-image-unable-to-run-on-different-port%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory