Example of docker compose building 2 containers please

Hi have 2 docker images I created. In my home directory I have 2 build directories.

WebApp
ProxyApp

both using NGINX. I have dockerfiles for each app in each folder. I can build them separately and run them fine. I’m trying to figure out how to use docker-compose to build them both and run them. Could someone give me an example?

Thanks!

you could have a look at Jerome’s Teaching Project.

there you have 4 apps that get built.

Thanks! This is helpful. In my docker project I am having difficulty getting link to work in my compose.

I’m trying the steps above to figure this out. Will drop another note if I can’t resolve it. I’m on docker 1.12 on centos7 with docker-compose 1.13

I got it working but I had to shut down firewallD. Trying to figure out how it could be interfering.

The best way I’ve found for inter-container communication is to use docker networks rather than links.

In your compose file, create a network in the top level network section and then reference that network in the networks section of you service configs.

At that point, the containers should be able to communicate with each other by using the service names (and using the containers port rather than a host port exposed in a port mapping)