Logging from one docker container to another

2019-07-18 23:09发布

问题:

I think I am missing something linking docker containers. I have 2 containers, 1 running Jenkins and 1 running elk stack.

From the host I can easily get logs to flow to elk.. and linking the Jenkins container to the elk one via --link gets some generic events into the elk stack.

But want I really want is the Jenkins container to (via the Jenkins Notification plugin) to log builds into elk no matter what I try tcp or http the the port I use on the docker host nothing shows up.

On the host the port 3333 is input to the elk container (3333 is the port for logstash).

From the docker host I can just do something like "echo "hello new World" | nc localhost 3333" and elk picks it up.

I am starting elk first with this:

docker run -d --name elk-docker -p 8686:80 -p 3333:3333 -p 9200:9200 elk-docker

Then Jenkins with this:

docker run -p 8585:8080 -v $PWD/docker/jenkins/jenkins_home:/var/lib/jenkins -t jenkins-docker

I have also tried this linking the two with no success.

docker run -p 8585:8080 --link elk-docker:elk -v $PWD/docker/jenkins/jenkins_home:/var/lib/jenkins -t jenkins-docker

In Jenkins I have the job notifiers plug-in installed and I was trying to use a simple TCP to port 333 and get the main events of the Jenkins job showing up in Elk by using the URL 172.17.0.5:3333. 172.17.0.5 is the IP of the logstash container.