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”

  • Isolate PHP applications with Docker
  • aws cli cannot read from dynamodb docker container
  • When to use -type d-exec chmod 750 / 640 in docker
  • Push docker image to amazon ecs repository
  • RabbitMQ Cluster in Docker Container among different hosts
  • elastic beanstalk application can't find private docker image
  • 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.

  • docker 1.12 swarm : Does Swarm have a configuration store like kubernetes configMap
  • Installing Oracle database in docker container
  • Amazon Elastic Beanstalk vs EC2 instance with docker containers
  • Why does Docker keep around the stopped containers?
  • Docker Compose V2 network error
  • Choose available memory for containers in Rancher
  • 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.