admin管理员组

文章数量:1296917

I'm relatively new docker so I'm pretty sure I'm not doing something right. I have a Angular application, with .Net as the back end api. It works fine when I run it using Visual Studio, however it fails when I run it in docker.

Here is my docker file:

# Stage 1: Build the Angular application
FROM node:12.22.12 AS build_node
WORKDIR /frontend
copy . .
RUN npm cache clean --force
RUN rm -rf node_modules
RUN rm package-lock.json

RUN npm install

EXPOSE 4200
CMD ["npm", "start"]

# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft/dotnet/aspnet:8.0-noble AS base
USER $APP_UID
WORKDIR /app

# This stage is used to build the service project
FROM mcr.microsoft/dotnet/sdk:8.0-noble AS build
ARG BUILD_CONFIGURATION=development
WORKDIR /src
COPY ["ProjectName.csproj", "."]
RUN dotnet restore "./ProjectName.csproj"
COPY . ./
Expose 5000
Expose 5001

CMD ["dotnet", "watch", "run"]

here is my docker-compose.yml file

version: '3.8'

services:
  angular:
    build:
      context: .
      dockerfile: Dockerfile
      target: build_node
    ports:
      - "4200:4200"

  dotnet:
    build:
      context: .
      dockerfile: Dockerfile
      target: build
    ports:
      - "5000:5000"
      - "5001:5001"
    depends_on:
      - angular

In my terminal when I run: docker-compose up --build there are no errors, and I get the following output:

 [+] Running 2/2
 ✔ Container cbas-angular-1  Recreated                                                                                                                                                                      0.1s
 ✔ Container cbas-dotnet-1   Recreated                                                                                                                                                                      0.1s
Attaching to angular-1, dotnet-1
angular-1  |
angular-1  | > [email protected] start /frontend
angular-1  | > ng serve --aot --proxy-config proxy.config.js --hmr -e=hmr
angular-1  |
dotnet-1   | dotnet watch ⌚ Polling file watcher is enabled
dotnet-1   | dotnet watch 

本文标签: angularUnable to access web application after containerizationStack Overflow