Docker in Hyper-V Image

Using Docker in a Hyper-V image can be that easy – if you know how to do that. The use case is quite simple: imagine you have a company or private infrastructure that runs on a server. This server runs multiple instances of Windows (Server) where one instance is used for developing and another for testing. Now if the assignement is to create a Docker image that runs your application than you might have the same problems that I had – I didn’t work on a fast try. So here is the short and simple solution of a few hours of trying and searching.

Preferences Hyper-V Host

  1. Start Hyper-V-Manager
  2. Write down name of the image that should run Docker for Windows
  3. Download the following script
    https://github.com/MicrosoftDocs/Virtualization-Documentation/blob/live/hyperv-tools/Nested/Enable-NestedVm.ps1
  4. Open powershell as Administrator
  5. Execute script
powershell -ExecutionPolicy Bypass -File .\Enable-NestedVm.ps1 {Hyper-V-image-name-that-should-run-Docker}

Explaination
-ExecutionPolicy Bypass: by default, no one is allowed to execute unsigned scripts, so bypass this setting. Just try it out without this parameter and you will see the response.
-File: the file to execute

Preferences Hyper-V Image

  1. Enable Windows Features
    + Containers
    + Hyper-V
  2. Download
    https://docs.docker.com/docker-for-windows/install/
  3. Install Docker
  4. Concratulation, you successfully installed Docker in a Hyper-V image!

IP Watcher

What is it good for? I have a homepage and dynamic IP address that changes after an arbitrary timespan. When the change happens I can’t reach my server. To get it work again I have to adapt the IP location manually. I know there exists e.g. dyndns… or upgrade to a static IP but I want to save money and have no problems in doing it.

Here is a script that compares the current IP address with a stored one and sends the new by email to a user defined address:

#!/bin/bash
MYIP="/home/user/myip.txt"
GETIP4ADDR="wget -qO- http://ipecho.net/plain | xargs echo"
GETIP6ADDR="wget -qO - icanhazip.com"
IPADDR=$($GETIP4ADDR)
EMAIL="sendmail -f noreply@sender.com receiver@email.com"

if [ -f "$MYIP" ]; then  
  LASTIP="$(cat $MYIP)"
  if [ "$IPADDR" != "$LASTIP" ]; then
    # IP changed
    echo "$IPADDR" > $MYIP
    echo "subject: IP Update $IPADDR" | $($EMAIL)
  fi
else
  # file missing, create file
  echo "$IPADDR" > $MYIP
  echo "subject: IP Update $IPADDR" | $($EMAIL)
fi

Hints

  1. sendmail
    sudo apt install sendmail
    sudo sendmailconf
  2. Adapt
    MYIP file location
    sender email address
    receiver email address
  3. Add script to your cron jobs, e.g. twice a day

Yahoo Mail Forwarding Fix

At the beginning of 2021 Yahoo is tighten up their email settings and therefore only paying customers are allowed to redirect their emails to another account. To bypass this you can do the following steps:

  1. Open your favorite web-browser and login to your Yahoo account
  2. Click on your name and open “Account Information”
  3. Click on “Account Security”
  4. Click on “Manage App Security”
  5. Select e.g. “Outlook Desktop” and a new password is presented. Let this site open or copy/paste it in a text editor. You will need it in a later step.

After you have a new app password, open your favorite web-browser and login to your e.g. Outlook account

  1. Click on “Settings”
  2. Click on “Show All Settings”
  3. Click on “Email”
  4. Click on “Email sychronization”
  5. “Add additional email accounts”
  6. Enter your Yahoo user (full email) and use the app password which was generated in the previous step
    pop.mail.yahoo.com, port 995, SSL
    imap.mail.yahoo.com, port 993, SSL
    smtp.mail.yahoo.com, port 587, SSL, use authentification
  7. Test by sending an email to your Yahoo account
  8. Congratulation you did bypass the new Yahoo restrictions 😉