Accessing Admin UI running on docker
See original GitHub issueHello guys.
I’ve been trying to make this application to run inside multiple docker containers. I have already managed to do it but only with the Admin.Api project and the STS.Identity project, but I’m having problems with the Admin.UI project.
Everytime I try to access the url (http://localhost:9000) it shows this error:
OException: IDX20804: Unable to retrieve document from: ‘identity-server-sts:5000/.well-known/openid-configuration’. Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel) InvalidOperationException:` IDX20803: Unable to obtain configuration from: ‘identity-server-sts:5000/.well-known/openid-configuration’. Microsoft.IdentityModel.Protocols.ConfigurationManager<T>.GetConfigurationAsync(CancellationToken cancel)
I read that is possibly something related to the way I configure my network containers, but I tried everything I found on the internet and nothing worked.
I tried to instead using http://localhost:5000, I changed the url to connect to the following:
- http://(ip of the host):5000
- http://(ip of container hosting the STS.Identity Application):5000
- http://(container name, in my case is: identity-server-sts):5000
- (container name, in my case is: identity-server-sts):5000
- (container name, in my case is: identity-server-sts)
I dont know what should I do, do guys have any idea what this error is about.
Here is my Dockerfiles of each project and my docker-compose file:
Dockerfile - Admin.UI Project
Dockerfile - Admin.API Project
Dockerfile - STS.Identity Project
docker-compose file
Issue Analytics
- State:
- Created 4 years ago
- Comments:22 (16 by maintainers)
I think we have a case here of misunderstanding how docker and docker-compose works on a network level, together with the working of xip.io DNS resolving. Docker-compose basically starts up a mini virtual network.
Each container can be considered as a tiny machine with its own IP address inside that network. If you want those little machine to work together you can refer to them by the name in the docker -compose. Look at the connection string of the database for instance. The connection string has the server
db
which matches the name of the docker container running SQL server. Note how each machine has a container name specified, for instanceNow, what does “localhost” mean from the perspective of a container? Well, as they can be considered as a little machine, then to each machine, localhost resolves to itself, not the localhost of your host machine (on which you run docker). Further, any address of xip.io resolves to
localhost
, thus depending on where you run that command, the machine responding will be the machine you run the command on. In our case here, the API and Admin UI, run on different “machines”, thus whilehttp://127.0.0.1.xip.io:9000
resolves perfectly on Admin UI, it will not findhttp://127.0.0.1.xip.io:5000
, because API is not running on the “machine” of the Admin UI. If you want to resolve from one docker image to another, you need to refer to them with their docker name. Each container may expose a port to the outside network and make it accessible to the “localhost” of your host machine. If you then callhttp://127.0.0.1.xip.io:5000
andhttp://127.0.0.1.xip.io:9000
on your host machine, each will resolve the correct machine, which is something that will not work if you try to resolve these on the individual containers themselves, since their localhost is their own “localhost”, not the “localhost” of the host.Unfortunately, OAuth requires a fqdn (fully qualified domain name) for the issuer. That means we cannot use the container names (as they are not fqdn) hence the usage of xip.io instead of the docker name resolving.
If you ran the seeding of the database, based on localhost instead of
127.0.0.1.xip.io
, then that configuration will not work inside a docker-compose env as the resolving will be incorrect when called from the docker host.So, basically this is likely a case of incorrect configuration of both the seeding and the docker-compose file.
To confirm, could you try out the example of the dev branch? But keep in mind that you need create the migrations before building and running as the migrations as not part of the source code, you need to generate that yourself. Start from a fresh database and use the
docker-compose.yml
as provided in the branch. There are a lot of env variables configured in each container which are ALL required to have the whole thing work correctly.That all being said, how would you get rid of that xip.io configuration?
extra_hosts
option of docker-compose.We choose the xip.io configuration together with proper env variables as it would not require extra network configuration outside docker and thus just work out of the box for development purposes. This configuration is not meant to be used in production. Then again, you would not use docker-compose in a production environment anyway.
Hi guys,
I’ve been trying to get this working for a couple of days now and I’m out of ideas. I think the issue is the same as that experienced in this issue and I think it’s a simple configuration issue. I’m setting this up on my mac with the plan to move it to a linux server once I’ve got it working.
I’ve replaced my FQD with example.com and I created a real DNS entry for that domain name resolving to public IP of my mac. Once deployed I’ll move the FQD to the public IP of my VPS.
When running the application in this exact configuration without TLS/HTTPS set in the Caddyfile (and changing the URLs everywhere to http) the whole stack works beautifully.
After changing the Caddy config to use HTTPS and setting the URLs everwhere (including the db) to HTTPS the STS application, API and swagger seems to be working fine.
There is a problem with the admin app where it throws the following exception anytime it’s accessed:
My hunch is that there is missing or incorrect configuration in the skoruba.identityserver4.admin container that doesn’t know how to work with the HTTPS configuration.
URLs:
Caddyfile:
Docker compose file:
App Settings & Certificates:
URLs in seeded data: