Executing a .bat script when starting a windows docker container

  batch-file, cmd, docker, visual-studio, windows

I’m setting up a windows container running a windows image with visual studio 2019 build tools. To set up correctly, I need to run the .bat file "vcvarsall.bat" that is inside the container (located in C:Program Files (x86)Microsoft Visual Studio19CommunityVCAuxiliaryBuild) whenever we start up the container.

This allows me to compile projects using cl and link from the command line. Here’s my current Dockerfile :

FROM abrarov/msvc-2019

COPY eigen C:UsersContainerUserDocumentslibraries;

RUN setx path "%path%;c:cmakebin";
RUN setx path "%path%;C:Program Files (x86)Microsoft Visual Studio19CommunityVCAuxiliaryBuild";
ENTRYPOINT vcvarsall.bat x86_x64

This executes the script whenever I run the container with docker run --rm -ti myContainer, but terminates the container as soon as it ends executing the script. As far as I understand, this is normal behavior of ENTRYPOINT, but I want to stay inside the container and be able to interact with it. How can I work around this? Is there a way to launch a new cmd.exe so that the process doesn’t end until the user types exit?

Source: Docker Questions