Edit: This has been updated to denote the latest version: v2.0. View here.
If you’ve been on twitter today, you’ve noticed quite a bit of buzz around the Sitecore Universe (SCUniverse – Pronounced “skju nɪ vɜrs”) with the news that Sitecore 10 has dropped! Play Marketing Buzzword Bingo with the Press Release here: https://www.sitecore.com/company/news-events/press-releases/2020/08/marketers-and-it-pros-jointly-win-with-launch
Of course, a major developer Quality of Life enhancement here is the native support of Containers. These containers allow you to quickly spin up and down new instances of Sitecore, without all the messy steps of installing SQL, Solr or even IIS (note: You’ll want to stop IIS before running the containers as there’s a port conflict on 443 otherwise). Check out the getting started guide here: https://containers.doc.sitecore.com/docs/run-sitecore. All in all, quite a helpful guide!
If you’ve followed this blog for any amount of time, you know there’s a pretty nifty tool I created, based on some prior works, that will automatically update your hosts file for you, removing that manual step. It’s exceptionally handy as you work with docker and end up creating more aliases (like for multi-tenant instances) for your site. It’s called Windows Hosts Writer, or WHW, and it’s a container that does exactly that: It updates your hosts file with your running containers.
It makes sense to use this with Sitecore 10, given Sitecore’s native support of Docker. How hard is it to configure WHW? Check out the steps below:
Step 1: Save the contents of the following to a file named docker-compose.override.yml and place it in the same folder as your docker-compose.yml. (You can directly download the file here.)
version: "2.4"
services:
id:
networks:
default:
aliases:
- ${ID_HOST}
cm:
networks:
default:
aliases:
- ${CM_HOST}
cd:
networks:
default:
aliases:
- ${CD_HOST}
hostswriter:
image: rahnemann/windows-hosts-writer:2.0-nanoserver-1909
volumes:
- C:\windows\system32\drivers\etc:C:\driversetc
- type: npipe
source: '\\.\pipe\docker_engine'
target: '\\.\pipe\docker_engine'
environment:
TERMINATION_MAP: id,cm,cd:traefik
Step 2: Run “docker-compose up -d”
Step 3: Crack open a cold one, because that’s it.
When your containers spin up, you should see something like the following:
Notice that traefik, CM, CD and ID all share the same IP. Magic? Yes, pretty much. Special thanks to Gabe for being my crash test dummy beta tester for this!
If you have any issues with WHW, drop a comment below.
I thought this should work as is on Windows 11?
Unfortunately, it does not work.
Am I doing something wrong?
HostWriter:
image: rahnemann/windows-hosts-writer:1.5-nanoserver-1909
networks:
dev.local:
volumes:
– C:\windows\system32\drivers\etc:C:\driversetc
– source: ‘\\.\pipe\docker_engine’
target: ‘\\.\pipe\docker_engine’
type: npipe
environment:
TERMINATION_MAP: id,cm:traefik
That should work. Have you tried it without the specific network and using the default?