question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage (docker) without --link

See original GitHub issue

I tried setting up Omniboard as described in the docs as follows

docker run --name sacred-db -p 27017:27017 -v /path/to/database/:/data/db -d
docker run -it --rm -p 9000:9000 --name omniboard --link sacred-db:mongo vivekratnavel/omniboard -m mongo:27017:sacre

and everything is working as expected.

However, reading from the docker documentation, I see that --link is deprecated

Warning: The --link flag is a legacy feature of Docker. It may eventually be removed. Unless you absolutely need to continue using it, we recommend that you use user-defined networks to facilitate communication between two containers instead of using --link

What is the preferred way to run through docker without using the --link option?

I tried

docker network create sacred-network
docker run --name sacred-db -p 27017:27017 -v /path/to/database/:/data/db -d --net=sacred-network mongo
docker run -it --rm -p 9000:9000 --name omniboard vivekratnavel/omniboard --net=sacred-network -m mongo:27017:sacred

But it I only get a failed to connect to server error:

> omniboard@0.0.4 prod /usr/omniboard
> cross-env NODE_ENV=production node dist/index.js "--net=sacred-network" "-m" "mongo:27017:sacred"

Omniboard is listening on port 9000!
2018-11-13T11:41:53.551Z 'MongoNetworkError: failed to connect to server [mongo:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongo mongo:27017]'
Retrying in 20 seconds...
Retrying first connect...
(node:29) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
2018-11-13T11:42:13.556Z 'MongoNetworkError: failed to connect to server [mongo:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongo mongo:27017]'
Retrying in 20 seconds...
Retrying first connect...
2018-11-13T11:42:33.554Z 'MongoNetworkError: failed to connect to server [mongo:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongo mongo:27017]'
Failed to establish connection to mongodb://mongo:27017/sacred after 2 retries. Exiting now...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! omniboard@0.0.4 prod: `cross-env NODE_ENV=production node dist/index.js "--net=sacred-network" "-m" "mongo:27017:sacred"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the omniboard@0.0.4 prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-11-13T11_42_33_587Z-debug.log

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
vivekratnavelcommented, Nov 13, 2018

@loeiten Sorry! I missed your mongo container creation part in the first comment.

Could you please try this?

docker run -it --rm -p 9000:9000 --name omniboard --net=sacred-network vivekratnavel/omniboard -m sacred-db:27017:sacred

Here hostname should be the name of your mongo container. In the docs, it is mongo because of alias used in link. Please let me know if the above command doesn’t work.

1reaction
vivekratnavelcommented, Nov 14, 2018

Updated the docs with --net. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Legacy container links | Docker Documentation
When you set up a link, you create a conduit between a source container and a recipient container. The recipient can then access...
Read more >
How to link containers in docker? - Stack Overflow
For inter-container dependencies and links, you'll want to use docker-compose where you can define the links between containers.
Read more >
Docker Tutorial Series : Part 8 : Linking Containers
In this part, we shall take a look at how to link Docker Containers. By linking containers, you provide a secure channel via...
Read more >
How To Communicate Between Docker Containers
How to use the default bridge network · Check that the bridge network is running: You can check it's running by typing docker...
Read more >
Docker Compose Networking - Runnable
Container IP addresses change on update. Reference containers by name, not IP, whenever possible. Otherwise you'll need to update the IP address you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found