Search code examples
dockerdocker-composedocker-registrydockerhub

docker compose pushing to docker hub


I have a docker-compose file which has 3 services, the yaml file works but how do i push this into registry as a single image and retrieve this is AWS Fargate so it spins up container ?

What are my options to spin up multiple containers as images are pushed into separate repositories.

This below is my Docker-compose.yaml file

version: '3.4'

services:
  dataapidocker:
    image: ${DOCKER_REGISTRY-}dataapidocker
    build:
      context: .
      dockerfile: DataAPIDocker/Dockerfile
    environment:
      - DB_PW
    depends_on:
      - db
  db:
    image: mcr.microsoft.com/mssql/server
    environment:
      SA_PASSWORD: "${DB_PW}"
      ACCEPT_EULA: "Y"
    ports:
      - "1433:1433"
  proxy1:
    build: 
      context: ./proxy
      dockerfile: Dockerfile 
    restart: always
    depends_on: 
      - dataapidocker
    ports:
      - "9999:80"

Solution

  • The method which i tried was creating two application First application : A nodejs express api server running at port 3001 with axios also attached Second Application : A nodejs express api server running at port 3010 with /data(can be anything) path to return some data, with cross origin access allowed.

    What i did was from first application, using axios.get command i queried localhost:3010/data to and printed it.

    Now create a separate dockerfile image of both.When you run them they might not work as they are querying the localhost.

    Create a taskdefinition into awsfargate and launch the task. Access the public IP of first container you will be able to receive the data from the second container just by querying the localhost, as fargate has them in the same network.

    If you want the code i can share them.