connecting to services on docker host from docker container
Apologies for asking two unrelated questions.
what is the best way of accessing the host machine of the docker container (i.e. I am trying to access a kafka instance running on the host, from my docker container so that I can publish some messages)
- How to connect to a remote socket in docker/engine-api?
- Changing a postgres containers server port in Docker Compose
- ps --filter does not work with -H
- Docker compose - access data from container A in container B
- How to use Java Buildpack in Bluemix Docker?
- Dropping priviliges inside of the container
when I run
docker run .....on an image which I’ve modified that may have an issue/syntax error, it will naturally not start – is there a log file anywhere that I would be able to take a look at to debug the issue. (this question is somewhat related to the 1st question, since I did what was suggested on another post, but the image is still not starting)
2 Solutions collect form web for “connecting to services on docker host from docker container”
This is an ongoing discussion on what to use and what not, I don’t really know what is best. Using the
docker run --net="host"is pretty easy but can be dangerous. See From inside of a Docker container, how do I connect to the localhost of the machine?.
docker logs containeridor lookup the raw data in
You should have no problem connecting to the host using the local lan interface ip address. Suppose you have a host with ip 192.168.0.1:
docker run –rm -ti ubuntu bash
should give you a response.
- You can use docker logs to see the standard output of your container.