I'm using a Docker Compose file to spin up a version of fluentd as follows:
version: '3'
services:
fluentd:
image: "fluent/fluentd:latest"
ports:
- "9880:9880"
- "24224:24224"
volumes:
- ./config:/fluentd/etc
- ./data/fluentd/logs:/fluentd/logs
environment:
- FLUENTD_CONF=fluentd.conf
This launches a network called project_default and then launches fluentd.
I then want to connect to that fluentd instance from a vanilla Docker container containing an application that I'm currently developing. As far as I can tell from the documentation I should be able to run the container and connect to the fluentd instance using the following command:
docker run --network=project_default -e FLUENTHOST='fluentd' myapp:1.0.0
where the FLUENTHOST environment variable passes the host name that fluentd should be running on.
When I run this I get a "lookup 'fluentd': no such host" error message.
Am I missing a step in either my Docker Compose file or my docker run command?
In your docker-compose file, you need to specify custom netwok driver bridge.
networks:
your_network_name:
driver: bridge
and then run your another container by using --network="your_network_name" flag
I am having similar kind of approach but I am running both containers by different docker-compose file, have a look.
docker-compose file to run Container 1 on custom network name code-network
version: '2'
services:
container_1:
build: container_1
networks:
- code-network
networks:
code-network:
driver: bridge
docker-compose file to run Container 2 to run on already existing network code-network
version: '2'
services:
container_2:
build: "container_2"
networks:
- code-network
networks:
code-network:
external: true
With above both container 1 and container 2 are running on same network, hope this will help you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With