Sign inSign up

ghstahl/httpcaller

By ghstahl

•Updated almost 6 years ago

Test image to call out from a container to test docker compose bridge

Image
0

895

ghstahl/httpcaller repository overview

This is a dotnet core 3.1 build

⁠Create Certs

dotnet dev-certs https -v -ep c:\temp\cert-aspnetcore.pfx -p ufo
dotnet dev-certs https --trust

⁠.env

ASPNETCORE_URLS=https://+:443;http://+:80
ASPNETCORE_KESTREL_CERTIFICATE_PASSWORD=ufo
ASPNETCORE_KESTREL_CERTIFICATE_PATH=/root/.dotnet/https/cert-aspnetcore.pfx
NUGET_SOURCE=https://api.nuget.org/v3/index.json
CERTIFICATE_PATH=c:\temp\

⁠Micro Service

⁠docker-compose-sampleexternalservice.yml

version: '3.8'

services:
  sampleexternalservice:
    image: ghstahl/sampleexternalservice:latest
    volumes:
      - ${CERTIFICATE_PATH}:/root/.dotnet/https
    ports:
      - 7300:80
      - 7301:443
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=${ASPNETCORE_URLS}
      - ASPNETCORE_Kestrel__Certificates__Default__Password=${ASPNETCORE_KESTREL_CERTIFICATE_PASSWORD}
      - ASPNETCORE_Kestrel__Certificates__Default__Path=${ASPNETCORE_KESTREL_CERTIFICATE_PATH}
      - ASPNETCORE_HTTPS_PORT=7301

⁠Consumer of MicroService

⁠docker-compose-httpcaller.yml

version: '3.8'

services:
  httpcallerservice:
    image: ghstahl/httpcaller:latest
    volumes:
      - ${CERTIFICATE_PATH}:/root/.dotnet/https
    ports:
      - 7400:80
      - 7401:443
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=${ASPNETCORE_URLS}
      - ASPNETCORE_Kestrel__Certificates__Default__Password=${ASPNETCORE_KESTREL_CERTIFICATE_PASSWORD}
      - ASPNETCORE_Kestrel__Certificates__Default__Path=${ASPNETCORE_KESTREL_CERTIFICATE_PATH}
      - ASPNETCORE_HTTPS_PORT=7401
    networks:
      - local

networks:
  local:
    driver: bridge

Notice the driver:bridge

I have 2 docker-compose.yml(s) running;

  1. A micro service
  2. A caller (this) that consumes the microservice.

⁠Local Urls

https://host.docker.internal:7301

This is the DNS entry that the contained HttpCaller app needs to resolve the IP address of the HOST (my windows machine)

My micro service expose port 7301. When I want to call this from Visual Studio, then localhost:7031 works and resolves to the right ipaddress.

Make sure the .env file is in the same folder as the docker-compose-*.yml(s)

docker-compose -f ./docker-compose-sampleexternalservice.yml up

https://localhost:7301/swagger/index.html
docker-compose -f ./docker-compose-httpcaller.yml up

https://localhost:7401

⁠Test Urls

baseUrl: https://host.docker.internal:7301
RouteAndQuery: zep/api/Consent/.well-known/consent-configuration

baseUrl: https://jsonplaceholder.typicode.com
RouteAndQuery: todos/1

Tag summary

Content type

Image

Digest

Size

81.7 MB

Last updated

almost 6 years ago

docker pull ghstahl/httpcaller