Connect to Dockerized IIS remotely - iis

I have run an IIS from the official image (https://hub.docker.com/r/microsoft/iis/)
on windows Server 2016
Is there any way to connect to that IIS from an IIS Manager so I could have a GUI Access to that IIS?

I don't have a solution for you, but I do have a recommendation:
The core concept behind Docker is that all your application configuration is expressed as code. I recommend creating a Dockerfile (one per service) which uses FROM microsoft/iis and configure the site within, including all site files. This ensures that wherever your created image is launched, it will run exactly as you designed.
Docker is a paradigm shift. I wouldn't recommend expecting things to work exactly as they did before.

Use the following docker file:
FROM mcr.microsoft.com/windows/servercore/iis
SHELL [ "powershell" ]
#setup Remote IIS management
RUN Install-WindowsFeature Web-Mgmt-Service; \
New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; \
Set-Service -Name wmsvc -StartupType automatic;
#Add user for Remote IIS Manager Login
RUN net user iisadmin Password~1234 /ADD; \
net localgroup administrators iisadmin /add;
Build it using docker build -t iisremote .
Run it using docker run --name remoteiis -d iisremote
Get the IP address of the container using docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' remoteiis
Connect to the container in IIS using the IP address optioned above
and the username and password used in the dockerfile
If you do not have the option in IIS to connect to a server, then you will need to install IIS Manager for Remote Administration from here. See this serverfault question for more info.
Note
When I tried creating a container directly from the IIS image (without the local dockerfile), connecting to the container using a terminal, and running the same powershell commands (that are in the dockerfile above) directly in the container terminal it does not work.
Source
https://devblogs.microsoft.com/premier-developer/iis-remote-management-for-docker-containers/

There is a solution to it, which contains of following parts.
1. You need to create local username/password in Container Image
2. You need to install IIS configuration tools
Detailed instructions are in walkthrough below
https://github.com/artisticcheese/artisticcheesecontainer/wiki

Related

self-hosted agent is not working for docker container

Problem:
We are trying to run self-hosted agent on my Windows 10 (Enterprise) machine using docker-container approach as explained in article. We can create docker image successfully (for Windows) as explained in mentioned article but while executing the created image with run command we are getting below error. We tried to google it but didn’t find any resolution.
Error:
Determining matching Azure Pipelines agent...
Invoke-RestMethod : The remote name could not be resolved: 'dev.azure.com'
Steps Followed:
Installed docker engine on my Windows 10 laptop
Followed instructions mentioned in aforementioned article and able to create docker image with docker build command.
But while running below command to run created docker image, we are getting above error.
docker run -e AZP_URL="https://dev.azure.com/MyOrg/" -e AZP_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXX" -e AZP_AGENT_NAME="LocalSelfHostTest1" -e AZP_POOL="LocalSelfHostTest" dockeragent:latest
XXXXXXXXX – PAT generated for my project.
We’ll appreciate your help.
Regards
arvind

Azure Container Instances no internet access for Windows Container?

My Windows Container in Azure Container Instances does not seem to be able to access the internet.
What can I do to access the internet from my Windows Container?
I had to execute this PowerShell command in the container during startup:
Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).IfIndex -ServerAddresses ('8.8.8.8')
Then my container was able to successfully resolve DNS and access the internet.
Executing this script in a RUN did not work, so I had to somehow execute it together with my already required CMD. I ended up doing it like this and it works:
CMD ["powershell", "-Command", "\"Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).IfIndex -ServerAddresses ('8.8.8.8')\"; cd c:\\app; .\\my.exe ui"]
Don't forget to escape \ and ".

How to reconnect to docker instance

I'll start from the beginning.
I've created an Ubuntu machine with docker installed on Azure.
On the top I created two docker containers, I used to connect from an old computer using docker-machine for management tasks.
I've changed my computer, so I need to connect from the new one.
I've added my azure subscription
However when I try the docker-machine cdmdlet to the existing container I have the following error message:
PS C:\WINDOWS\system32> docker-machine ssh vm name
Host does not exist: "vm name".
The machine is running but I'll guess I'll have to recreate the certificates used for the connection.
I've tried the following with no luck:
PS C:\WINDOWS\system32> docker-machine regenerate-certs vm name
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Host does not exist: "vm name"
I no longer have access to the old machine.
Has anyone been into the same situation?
Any thoughts are welcome.
You'll have to recreate the machine using the generic driver:
docker-machine create \
--driver generic \
--generic-ip-address=203.0.113.81 \
--generic-ssh-key ~/.ssh/id_rsa \
vm
Replace the information accordingly.
Note that this does NOT remove any data on the target instance, rather it just configures docker to talk to machine if it isn't already, and also generates new certificates so it can communicate with the instance.

How to enable the Docker Remote API on Windows

I am trying to use the Docker Remote API on a Windows 10 host machine. I am using Chrome's Postman extension to see if I can get results from the docker remote api's endpoints. Here are the endpoints that I've tried:
GET http://192.168.99.100:4243/images/json
GET http://192.168.99.100:2376/images/json
Both returned Connection to server 192.168.99.100 failed (The server is not responding)
After a few searches I found out that the Docker Remote API is not enabled by default on Windows. Most of the guides are for Ubuntu but I have found this particular one for Windows.
These are the steps that I performed on my machine
docker-machine ssh
cd /var/lib/boot2docker
sudo vi profile
Change DOCKER_HOST='H tcp://0.0.0.2376' to DOCKER_HOST='H tcp://0.0.0.2375'
change DOCKER_TLS=auto to DOCKER_TLS=no
export DOCKER_HOST='-H tcp://0.0.0.2375'
export DOCKER_TLS_VERIFY=0
env | grep DOCKER
docker-machine restart
docker-machine env
docker-machine regenerate-certs
After performing the steps above, I did try again the endpoints on Postman but I still get the same result.
Can you perhaps give a little help if I have missed a step? Or am I on track?
Also, to answer some of my queries.
Is the docker remote api port for Windows 2375 and 4243 for Linux?
Is DOCKER_HOST for Windows and DOCKER_OPTS for Linux?
Switch your docker to windows container
Got to C:\ProgramData\Docker\config
in deamon.json file
add "hosts": ["tcp://0.0.0.0:2376", "npipe://"]
restart docker.
give command : docker -H tcp://0.0.0.0:2376 ps
The Remote API is now enabled by default on Windows (see ticket here).
It is reachable at http:\\localhost:2375 indeed (tested it).
I faced the same issue and found a quick solution for this. Just open docker settings and enable "Expose daemon on TCP..." checkbox. Docker will start automatically and the problem should be solved.Please find the image attached for reference
using docker desktop, go to settings and check "Expose daemon on tcp://localhost:2375 without TLS"

Run IIS Windows container

I have followed this (IIS Windows Container) https://hub.docker.com/r/microsoft/iis/ and am running into this (Not authorised) https://github.com/docker/docker/issues/21558 is it just me? Am i doing something wrong? Or does this just not work yet?
I'm running Windows 10 (Build 14931) in VM Ware with Docker beta 1.12.2-Beta28
ps I don't have enough rep to create windows-containers as a tag...
No the Docker image is fine on Win10 - you may be hitting the loopback problem, where you can't connect via localhost or 127.0.0.1 because of a limitation in the Windows network stack.
Try this:
docker run -d -p 80:80 --name iis microsoft/iis
docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' iis
The second line will give you the NAT IP address of the container, and you should be able to browse to http://{container-ip} and see the IIS welcome page.
Incidentally, if you're using the VM just to work with Docker, you'd be better off using Windows Server 2016 - you can use Windows Server Containers instead of Hyper-V Containers, and they're quite a bit faster to start.
For future me / people having the same issue. Firstly definitely follow Elton's advice the links provided make for a much better dockerfile / experience when building the container. However the issue (for me) was that I don't think I was copying / adding the files to the build. {Oops} Still not clear what magic is done on the Nerd-dinner clone so that it imports the correct files but that gav e the hint I needed
https://github.com/sixeyed/nerd-dinner/blob/dockerize-part1/docker/Dockerfile
https://blog.sixeyed.com/windows-dockerfiles-and-the-backtick-backslash-backlash/

Resources