0

I am trying to build my app with docker but I need to be able to target windowsservercore-ltsc2016 (Windows 2016), windowsservercore-1709 & windowsservercore-1803.

The only thing I can think of is a separate dockerfile per architecture but that doesn't mean it is easy to update if there are changes in future. Changes would have to be made in n number of files.

Additionally is there an automatic way for when you run say a docker-compose file to easily figure out that you are running 1803 version and to use that or is it better to again create a docker-compose file for the architecture your using.

namokarm
  • 668
  • 1
  • 7
  • 20
StonesBG
  • 180
  • 5
  • Microsoft is using different dockerfile for each architecture. You can see example how they do it for dotnet core for example (https://github.com/dotnet/dotnet-docker/tree/master/2.1/runtime). Your base image will be automatically matched based on your client, so if you just put windowservercore then it will pull 1803 if you are on 1803 or ltsc if you are on ltsc – Gregory Suvalian Jul 13 '18 at 13:40

1 Answers1

0

Pass args to dockerfile, then do related based on the TARGETOS variable. This works on linux, for windows, I guess it is similar, just give you some thoughts.

CMD:

export TARGETOS=windowsservercore-1803
docker-compose build

docker-compose.yml:

services:
  my_name:
     build:
       context: .
       args:
         - TARGETOS

Dockerfile:

ARG TARGETOS
ENV TARGETOS ${TARGETOS}

# do things based on TARGETOS arg
# RUN if [ ${TARGETOS} = "windowsservercore-1803" ]; then \
atline
  • 28,355
  • 16
  • 77
  • 113