I recently learned that I could turn on experimentally features in Docker for Windows and run both Windows and Linux images simultaneously. Normally we need to switch between them, and you can run one or the other. The feature is here for some time now, but below is the 2021 short tutorial :).
1. Switch to Windows containers in Docker for Windows tray
2. Go to Docker Engine settings section and set experimental parameter to ‘true’
3. Apply and restart the docker
4. Run Windows nad Linux docker image
Let’s create a docker-compose file with 2 images:
- Windows Server Core with IIS (Windows container)
- SQL 2017 server (Linux container)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
version: '3.8' services: nanoserver: container_name: nanoserver image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-20H2 sql2017: container_name: sql2017 platform: linux mem_limit: 4GB environment: - ACCEPT_EULA=Y - MSSQL_PID=Developer - SA_PASSWORD=Mypass1. volumes: - 'c:/tmp/sql:/var/opt/mssql/data' ports: - '1433:1433' image: mcr.microsoft.com/mssql/server:2017-latest |
If you look carefully in the sql2017 section, you can see the parameter platform: linux. This specifies the platform on which you want to run the image. Save the file to dc-mixed.yml.
Now let’s run the docker-compose file and wait for the containers to download and run:
1 |
docker-compose -f .\dc-mixed.yml -p Demo up |
And that’s it; you are now running both Windows and Linux containers on Docker for Windows. Please note that this is an experimental feature, but I use it for development/test purposes.
Till next time!
Leave a Reply
You must belogged in to post a comment.