Getting outside-in with docker-compose[r] networks

Getting outside-in with docker-compose[r] networks


I had several docker containers spun up, all happily talking to each other on their own network. All happy for me to talk to them from the host Ubuntu system as well. Slight issue of when a configuration is exported from one of the docker containers, it was referring to the others by the domain it knew, – not so great to use it from the host that knew it via localhost.

Ah, I can use sed to reformat the exported data – doable but not that elegant. A much more elegant solution occurred to me. Enter the /etc/hosts file

So to recap the scenario…

We use docker and docker-composer in Composer to set up a basic Fabric system and Composer Playground for developers. Now that we have Network Cards in the runtime and playground there’s a problem how do you export a card from Playground to use on the command line?

  1. Install a Fabric/Composerset up directly.If you want to do this now it’s the command
  1. This spins up a set of docker images that make up a simple Hyperledger Fabric – and also starts the Composer playground and brings this up in your browser.

  2. But as a developer you want to access this also from command line applications. You then install the composer-cli
    npm install -g composer-cli

  3. Exporting a Network Card form playground is great, until you come to then use it for real

This is because from your host command line, the hosts that are used in docker-composer network – don’t mean much from your host system.


Edit /etc/hosts so that the host names resolve to localhost

  • Rather than edit by hand, I came across hostess – a simple command line that edits the /etc/hosts
  • Download this from the github repo
  • chmod u+x hostesss_linux_amd64  to make it executable
  • sudo mv hostess_linux_amd64 /usr/local/bin/hostess  to put it on the path and give a simpler name
  • This now makes it very easy to add and remove and list entries from the /etc/hosts file.
  • So as this is was to make it easy to use the docker hosted version of the Hyperleder Composer Playground here’s the json file that contains the extra entries



  • Copy this to a simple text file named say fabrichosts.json
  • Run the hostess tool to import these
  • hostess apply fabrichosts.json

That’s it.

What this means is that from the docker-hosted version of the Composer playground, Network Cards can be exported that refer to the address – but they can be used from the command line with ease!

Leave a Reply

Your email address will not be published. Required fields are marked *