简体   繁体   中英

Azure Containers Docker Compose (preview) issue listening on port 8080

I want to deploy an Angular-based app using Docker Compose on Azure Web Apps for Containers.

I have already created a custom image of the application on our private repository, and here is the revamped version of the Docker Compose file

version: '3.8'
services:
  cnil-pia-back:
    container_name: pia-back
    image: example.azurecr.io/cnil-pia/pia-backend:latest
    restart: unless-stopped
    environment:
      DATABASE_HOST: 'database'
      DATABASE_USERNAME: 'postgres'
      DATABASE_PASSWORD: 'somepassword' # Please don't mind, we are testing for now
      SECRET_KEY_BASE: 'somesecret'
    links:
      - database
    depends_on:
      - database
    ports:
      - 8080:3000 # See comment later

  cnil-pia-front:
    container_name: pia-front
    image: example.azurecr.io/cnil-pia/pia-frontend:latest
    restart: unless-stopped
    ports:
      - 80:80

  database:
    container_name: pia-db
    image: postgres:13
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: 'somepassword'
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data: # Probably it won't work, but we are not discussing this

The backend application must be open to the internet, or at least firewalled . Anyway, Angular calls the backend from the browser, so both the front end application (serving Angular static resources) and the backend application must be accessible from the browser.

The problem is that neither port 8080 or 3000 are accessible from the client at the moment using the chosen DNS name, while the Angular application is.

I learned from Azure documentation that Docker Compose support has some limitations, including that only ports 8080 and 80 are supported.

I expected to deploy two containers, one listening on 80 (HTTPS-terminated by Azure) for the front end, and another to go well on port 8080, regardless of HTTPS

Here is an excerpt from the Docker logs

2021-07-12T09:47:15.514Z INFO  -  Status: Downloaded newer image for example.azurecr.io/cnil-pia/pia-backend:latest
2021-07-12T09:47:15.522Z INFO  - Pull Image successful, Time taken: 2 Minutes and 37 Seconds
2021-07-12T09:47:15.551Z INFO  - Starting container for site
2021-07-12T09:47:15.552Z INFO  - docker run -d -p 0:3000 --name example_cnil-pia-back_0_e65f2c35 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=example-app -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=example-app.azurewebsites.net -e WEBSITE_INSTANCE_ID=acc200cd5031529803448aa52023fe967882435b7dc689afd8df4117b5572ca3 example.azurecr.io/cnil-pia/pia-backend:latest  

Note that Azure Docker engine arbitrarily used 0 as listening port in the -p option.

Question is: how do I, if it's possible, expose two containers using Docker Compose on Azure?

The feature is in preview, and each Docker Compose stack only supports exposing the local port 80, which is TLS-terminated by Azure.

That means only one service in the stack can be accessible by the external. One can deploy a 3-tier service only if the front end layer internally calls the back end (eg server pages technology). But if the back end has to be exposed over internet, it must be deployed separately. Either in another Docker Compose stack, or as a single container

Are our problems the same? Should I also go the way of opening a separate instance? I am using AWS.

My front-end container running on Amazon EC2 is getting error ERR_CONNECTION_REFUSED

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM