A container B won’t be able to directly call localhost:9000 because the localhost inside of B is its own localhost! A container A running on port 9000, bound to its own internal IP (or 0.0.0.0 which is different) is local to its own view of the environment. They shouldn’t be able to view/access resources from the host machine directly. The basic premise of containers to isolate the processes running inside them from the host environment. I’ll share the nginx docker file below to preserve the narrative, but it mostly contains one single line: a COPY of the config I showed above to the nginx config folder, as documented in on the dockerhub page: dockerhub/nginx Container networking * Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas = Sinatra (v2.0.3) has taken the stage on 9000 for development with backup from Puma
DOCKER NETWORK MODE HOST INSTALL
1 EXPOSE 9000/ tcp WORKDIR / usr/ src/ hello- world RUN gem install - no- rdoc - no- ri sinatra puma COPY.
This will be customised with a specific nginx configuration with reverse proxy setup.ĭockerfile.sinatra: FROM ruby: 2.
I recently tried to do this without docker-compose, and in this post I’m gonna share what I learnt. For what it’s worth, docker-compose provides a very easy way to do these kinds of things using declarative syntax, and in the background it configures a lot of things automatically to make that work. Optionally, I’d also want to run multiple such containers say one nginx container process in front of multiple Sinatra application containers. There’s no requirement for them to communicate with other containers running on other machines.
DOCKER NETWORK MODE HOST HOW TO
Understanding inter-container networking, or how to avoid docker-compose