John Giotta
John Giotta

Reputation: 16964

How Can I Link a Apache and Tomcat Containers Over AJP?

I'm created 2 Docker images. One is tomcat and the other is apache. I can get them to run individually, but I'm attempting to proxy the apache to tomcat over AJP

I understand that 2 running images are unaware of each, but is there any way to link the AJP port to the apache?

Currently I get the following:

[Thu Mar 17 15:49:43.373689 2016] [proxy:error] [pid 11:tid 140213099689728] (111)Connection refused: AH00957: AJP: attempt to connect to 127.0.0.1:8009 (localhost) failed [Thu Mar 17 15:49:43.373836 2016] [proxy:error] [pid 11:tid 140213099689728] AH00959: ap_proxy_connect_backend disabling worker for (localhost) for 60s [Thu Mar 17 15:49:43.373852 2016] [proxy_ajp:error] [pid 11:tid 140213099689728] [client 192.168.5.1:34864] AH00896: failed to make connection to backend: localhost 192.168.5.1 - - [17/Mar/2016:15:49:43 +0000] "GET / HTTP/1.1" 503 299

Upvotes: 0

Views: 3764

Answers (1)

Collin Estes
Collin Estes

Reputation: 5799

With docker you have several ways you can do this. The best way is to setup a docker bridge network (assuming you are running them on the same host). Also a running image is called a container.

To do this you have to do several things:

  1. Create a bridge network

    "docker network create my-net"

  2. Add the "--net=my-net" to your docker run command for both containers

  3. Update your connection info to use the container name as the host-name instead of using "localhost" or 127.0.0.1. (When you run containers on the same docker network, docker does some DNS magic where it makes them accessible through a hostname matching their container name.

EDIT:

If you are running a version prior to 1.9 you will have to use the "link" command: https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/

Or you could run both containers with --net=host which would give them access to one another over localhost. (problem with this is you lose the encapsulation of the container and it basically opens all ports of that container to the host.

Upvotes: 2

Related Questions