I have a kafka server in my local host, and i want to connect it in my docker container.
I had searched how to connect local services in docker container and i found this: how-to-connect-to-local-mysql-server-through-docker
But it didn't work. Please help me, thanks~
Try updating kafka config as shown below
$ nano config/server.properties
uncomment listeners and paste the following
listeners=PLAINTEXT://<local-ip>:9092
save file & restart kafka.
Hope this helps!
https://github.com/provectus/kafka-ui/discussions/1081
In my Kafka server.properties I had advertised.listeners=PLAINTEXT://localhost:9092. This only allow access via localhost. Once I changed it to my machine's IP address everything worked fine.
If I understand right, you question can be re-phrased as "How can I access my host machine withing my docker container".
As i wrote in another answer, you can set gateway when starting your container, create some kind of proxy to access your Kafka or take the host ip from container.
Related
I am trying for nginx proxy manager (running in a docker container) to connect to another docker container that has port 8080 open on it. When I setup the proxy to connect to 192.168.0.29:8080 the ip address of the host, but it doesn't work, the browser just says that the site didn't send any data.
I tried setting up the reverse proxy with other services (that weren't running inside a docker container), and they worked flawlessly. So, I've concluded, the problem is something with the docker containers.
First, I tried replacing the ip address with the address of the container (shown in portainer) which showed to be 172.17.0.2. But, that didn't work. I can confirm that both containers are in the same network, bridge.
I could not find any solutions for this problem either here, at Stack Overflow, or anywhere else. Hope there's enough data to solve this problem. Thanks ahead of time!
Edit:
running arp -na from within the container gives this output:
[root#docker-00244f7ab2cc:/app]# arp -na
? (172.17.0.1) at 02:42:d1:fc:fc:6b [ether] on eth0
I found the solution to my question after lots of searching and testing and it's quite simple. The solution is to start the nginx proxy manager docker container on the host network instead of the bridge network. Then, you can use localhost and then the port to refer to which service you want to redirect to.
Can someone point out how to setup kafka with docker? I have tried every tutorial I could find and I got the same error:
Can't resolve YYYYYYY:PORT adress where YYYYYYY is the container id
I tried using kafka listeners, kafka advertised host name, kafka port and kafka advertised listeners enviroment variables but nothing worked. I mapped all ports 9092:9092 and 2181:2181.
If someone has a working Dockerfile with kafka I would apreaciate it.
YYYYYYY:PORT adress where YYYYYYY is the container id
Without seeing your Dockerfile and the commands you've tried, sounds to me like you are not using localhost outside of the container to access the Docker image, or using the Docker image name, not the container ID.
If a tutorial is showing it working, then I wouldn't think seeing another Dockerfile would help... TBH, just seems like a misconception that the container ID is relevant; or even if you used the container name externally of the container, it's a network error because it is not available to your DNS servers
That all being said, Confluent Quick Start (Docker) gives a good overview of not just Kafka, but also Zookeeper and other Kafka related components
See https://github.com/confluentinc/cp-docker-images/blob/5.0.0-post/examples/cp-all-in-one/docker-compose.yml for an example of a working Docker Compose.
Also, you need to get your networking configuration right, as Kafka works across hosts and needs to be able to access them all. This post explains it in detail.
I have a docker container that needs to access an network server on the LAN. This server is visible from the docker host machine and I can access it from within the container when I reference the IP address directly.
However I need to be able to specify a url and port (e.g http://myserver:8080) rather than an IP address, which the docker container cannot resolve.
How can I configure the container to resolve this? ideally using the docker hosts dns. I have looked at many of the docs, but not being a DNS expert, it doesn't seem straightforward.
UPDATE:
I have tried this, which seems to work, but does this have any downsides or unintended consequences?
--network host
Thanks,
The rigth way to do this is to configure the docker daemon dns as specified under daemon-dns-options.
Using the host network is not recommended as it has some downsides https://docs.docker.com/network/host/
I need help with configuring docker on Debian 9.
I installed docker and docker-compose successfully.
I can access my host by IP (ex. 172.18.0.7), but cannot access by domain name (sitename.loc). I see an error "ERR_NAME_NOT_RESOLVED" or "DNS_PROBE_FINISHED_NXDOMAIN".
Commands
$ docker-compose up -d
$ docker ps
works fine.
I tried disable firewall, it didn't help.
What's wrong? iptables?
Thanks in advance.
You can add the IP and name to your hosts file, but the container IP can change everytime you start it, so a better approach is to map the ports to your host, and then add to the hosts file this mapping:
sitename.loc 127.0.0.1
I'm trying to access Docker remote API from within a container because I need to start other containers.
The host address is 172.19.0.1, so I'm using http://172.19.0.1:2375/images/json to get the list of images (from host, http://localhost:2375/images/json works as expected.
The connection is refused, I guess because Docker (for Windows) listens on 127.0.0.1 and not on 0.0.0.0.
I've tried to change configuration (both from UI and daemon.json) adding the entry:
"hosts": ["tcp://0.0.0.0:2375"]
but the daemon fails to start. How can I access the api?
You can set DOCKER_OPTS in windows as below and try. In Windows, Docker runs inside a VM. So, you have to ssh into the VM and make the changes.
DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'
Check if it works for you.
Update :- To ssh into the VM (assuming default is the VM name you have created using Docker toolbox), enter the following command in the Docker Quickstart Terminal,
docker-machine ssh default
You can find more details here.
You could link the host's /var/run/docker.sock within the container where you need it. This way, you don't expose the Docker Remote API via an open port.
Be aware that it does provide root-like access to docker.
-v /var/run/docker.sock:/var/run/docker.sock
You should use "tcp://host.docker.internal:2375" to connect to host machine from container. Please make sure that you can ping the "host.docker.internal" address
https://github.com/docker/for-win/issues/1976