I'm trying to run a second Meteor app in a Docker's container. The first (who is running as I want) is accessible with localhost:3000
and I want to run a second one in a other port like localhost:3003
. When I try to access the second I got this
This website is not accessible. Localhost don't allow the connexion. Do a research about localhost 3003 on Google.
And If I look into Docker I can see that my containers are running:
but I noticed a difference between the port, the one who is accessible is 0.0.0.0:3000->3000/tcp
and the one who isn't accessible is 3000/tcp, 0.0.0.0:3003->3003/tcp
so I think there is something wrong here.
And in my docker-compose.yml I did :
app:
image: jeromevi/controlcontainersapp
ports:
- "3003:3003"
environment:
- ROOT_URL=http://localhost:3003
- MONGO_URL=mongodb://mongo:27017/meteor
mongo:
image: mongo:latest
Thank you for the help
[EDIT] there are the logs :
=> Starting app on port 3000...
/opt/meteor/dist/bundle/programs/server/node_modules/fibers/future.js:313
throw(ex);
^
MongoError: failed to connect to server [mongo:27017] on first connect
at Object.Future.wait (/opt/meteor/dist/bundle/programs/server/node_modules/fibers/future.js:449:15)
at new MongoConnection (packages/mongo/mongo_driver.js:219:27)
at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
at new Mongo.Collection (packages/mongo/collection.js:103:40)
at meteorInstall.both.collections.infosContainers.js (both/collections/infosContainers.js:2:14)
at fileEvaluate (packages/modules-runtime.js:181:9)
at require (packages/modules-runtime.js:106:16)
at /opt/meteor/dist/bundle/programs/server/app/app.js:217:1
- - - - -
at [object Object].<anonymous> (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emitOne (events.js:77:13)
at [object Object].emit (events.js:169:7)
at [object Object].<anonymous> (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:271:12)
at [object Object].g (events.js:260:16)
at emitTwo (events.js:87:13)
at [object Object].emit (events.js:172:7)
at Socket.<anonymous> (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:165:49)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
[EDIT2] With the new config the errors are :
But I have the network testNtw:
NETWORK ID NAME DRIVER SCOPE
6767c4bf208f bridge bridge local
c69fbc3a59cf host host local
f6f5083df32e none null local
3d0aacdbb757 testNtw bridge local
And I did the same docker-compose.yml as in the answer
Try the following:
Docker Compose file:
Then check this url in your browser:
Clarification:
With default networking you need to use
links
that is a legacy feature. I recommend usingUser-Defined
networks.User-Defined
networks provide built inDNS
so you can connect to your containers from other containers on the sameUser-Defined
network byname
. In your case a container namedmongo
needs to be accessed from a container namedapp
.