无法使用docker-compose从docker容器内部访问https:// localhost:3000,但可以通过Mac上的DNS名称访问

时间:2020-07-06 22:40:33

标签: docker docker-compose

使用下面的docker-compose文件。

## shorten data frame for simplicity
df=Cars93[c(1:15),]
df=Cars93[is.element(Cars93$Make,c('Acura Integra', 'Audi 90','BMW 535i','Subaru Legacy')),]
df$Make=drop.levels(df$Make)
df$Model=drop.levels(df$Model)

## define contrasts (every factor has 4 levels)
contrasts(df$Make) = contr.treatment(4)
contrasts(df$Model) = contr.treatment(4)

## model
m1 <- lm(Price ~ Model*Make,data=df)
summary(m1)

由于运行状况检查,容器无法启动星标。

version: "2.4"
services:
  test-database:
    image: mcr.microsoft.com/mssql/server
    build: ms-sql-db
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: removed
      MSSQL_PID: removed
    tty: true
    ports:
      - 31433:1433
    volumes:
      - database-data:/var/opt/mssql
    healthcheck:
      test: nc -z localhost 1433 || exit -1
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 40s

  api:
    image: removed/api:1.0
    build:
      context: .
      dockerfile: Api/Dockerfile-dev
    depends_on:
      test-database:
        condition: service_healthy
    volumes:
      - ./Api:/app
    ports:
      - 5000:5000
      - 5001:5001
    tty: true
    healthcheck:
      test: curl --fail --insecure https://localhost:5001/api/health
      interval: 5s
      timeout: 5s
      retries: 3
      start_period: 40s
  ui:
    build:
      context: .
      dockerfile: webapp/Dockerfile-dev
    depends_on:
      api:
        condition: service_healthy
    volumes:
      - ./webapp:/app
      - /app/node_modules
    ports:
      - 3000:3000
    environment:
      - NODE_ENV=development
    healthcheck:
      test: curl --fail --insecure https://localhost:3000/
      interval: 5s
      timeout: 5s
      retries: 3
      start_period: 40s

但是,如果我使用docker-compose创建的容器的dns名称,如下所示,它将起作用。

      test: curl --fail --insecure https://localhost:3000/

我正在使用Mac和Docker桌面。

修改 为了清楚起见添加了特定问题。我的问题是在容器中,我只能访问 test: curl --fail --insecure https://ui:3000/ ,而不能访问https://ui:3000/,而我不希望将运行状况检查与服务名称结合使用。

0 个答案:

没有答案