Docker example for frontend and backend application

I am learning how to use Docker, and I am in a process of setting up a simple app with Frontend and Backend using Centos+PHP+MySQL.

I have my machine:
“example”

  • Running iPython Notebook in Docker container on Amazon EC2 instance
  • Use host networking and additional networks in docker compose
  • AWS cloud form task definition conditional command
  • Persistent mysql data from docker container
  • Opening a port from a docker container on AWS to the rest of the world
  • Where does docker store it's temp files during extraction?
  • In machine “example” i have configured 2 docker containers:

    frontend:
      build: ./frontend
      volumes:
        - ./frontend:/var/www/html
        - ./infrastructure/logs/frontend/httpd:/var/logs/httpd
      ports:
        - "80"
      links:
        - api
    api:
      build: ./api
      volumes:
        - ./api:/var/www/html
        - ./infrastructure/logs/api/httpd:/var/logs/httpd
      ports:
        - "80"
      links:
        - mysql:container_mysql
    

    The issue I am facing is when I access the docker container, I need to specify a port number for either FRONTEND (32771) or BACKEND (32772).

    Is this normal or is there a way to create hostnames for the API and Frontend of the application?

    How does this work on deployment to AWS?

    Thanks in advance.

  • Firefox Proxy to Docker Fiddler refusing connection
  • docker-compose links between app and db
  • Kafka setup with docker using kafka-rb for clients
  • deploy after gitlab runner completes build
  • How to disable chrome to use gpu in docker environment
  • Docker, where does the firewall go?
  • One Solution collect form web for “Docker example for frontend and backend application”

    If you’re running docker 1.9 or 1.10, and use the 2.0 format for your docker-compose.yml, you can directly access other services through either their “service” name, or “container” name. See my answer on this question, which has a basic example to illustrate this; https://stackoverflow.com/a/36245209/1811501

    Because the connection between services goes through the private container-container network, you don’t need to use the randomly assigned ports, so if a service publishes/exposes port 80, you can simply connect through port 80

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.