I run a mongodb in docker container with
docker run -p 127.0.0.1:27017:27017 -v /data/db:/data/db --name mongodb -d --rm mongo:3.4
and docker ps
:
da5789a63e57 mongo:3.4 "/entrypoint.sh --..." 18 hours ago Up 18 hours 127.0.0.1:27017->27017/tcp mongodb
then I run my app with --link
:
docker run -p 3000:3000 -v /data/app:/data/app --rm --name app --link mongodb:mongo <IMAGE>
and docker ps
:
b033802795fc brickyang/contest:1.1.0 "pm2 start --no-da..." 4 seconds ago Up 3 seconds 127.0.0.1:3000->3000/tcp app
There's no link name like mongo/app
as expected, and the app always throw an error about:
MongoError: failed to connect to server [localhost:27017] on first connect
If I start the app locally with npm start
(mongo in container), it works great.
via Brick Yang
No comments:
Post a Comment