Networking with Docker
Docker has some pretty nice networking options, from choosing which ports to expose to concurrently running isolated or bridged networks. It's pretty useful to quickly and easily simulate production environments, create better architectures, and increase container exposure on the network front. We'll see different ways to expose ports, create new networks, execute Docker containers inside them, and even have multiple networks per container.
Getting ready
To step through this recipe, you will need the following:
- A working Docker installation
- A sample HTTP server binary (sample code included)
How to do it…
To make a container network port available to others, it first needs to be exposed. Consider any service listening on a port not reachable unless properly exposed in the 3:
FROM debian:jessie-slim COPY src/hello/hello /hello EXPOSE 8000 ENTRYPOINT ["/hello"]
This service is listening on port 8000
, and any other Docker container running on the host...