-
Notifications
You must be signed in to change notification settings - Fork 207
Description
Goal
Support we want to support auth code flow in docker container, as opposed to #421.
Solution 1: --net=host
--net=host
is used to put the container directly in the host
network. Unfortunately, as mentioned in #309 (comment), --net=host
doesn't work on platforms other than Linux, like Windows or MacOS:
"(i.e. started by `docker run --net=host -it ...`), " |
So we have to use other approaches.
Solution 2: --publish , -p
I tried to use --publish , -p
to expose/map certain port like 8400
to the hosting Windows:
docker run -it -p 8400:8400 -v d:/cli/azure-cli:/root/azure-cli python:3.9 bash
cd /root
python -m venv pyenv
. pyenv/bin/activate
pip install azdev
azdev setup -c azure-cli
However, after running az login
, the browser fails with
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
This is because AuthCodeReceiver
only listens to 127.0.0.1
:
address = "127.0.0.1" # Hardcode, for now, Not sure what to expose, yet. |
As the container runs in bridge
network (docker inspect <name>
), the IP address is actually
# hostname --ip-address
172.17.0.3
It fails because the IP doesn't match.
This can be cross-checked with
python -m http.server 8400 --bind 127.0.0.1
Now visiting http://127.0.0.1:8400 from the host shows the same error message.
But if we listen to all port:
python -m http.server 8400
http://127.0.0.1:8400 works as expected.
Experiment
After changing
address = "127.0.0.1" # Hardcode, for now, Not sure what to expose, yet. |
to ""
, I can successfully do an auth code flow in a docker container!