Docker container built using Visual Studio does not contain source files RRS feed

  • Question

  • Hello,

    I have built a docker container using Visual Studio 2017. Basically I have an MVC application which i want to containerize for better deployments. Using Visual Studio, i was able to build and run the container, dockerfile:

    FROM microsoft/aspnet:4.7.1-windowsservercore-ltsc2016
    ARG source
    WORKDIR /inetpub/wwwroot
    COPY ${source:-obj/Docker/publish} c:/inetpub/wwwroot

    When i do a Visual Studio build, i see the following command running:

    docker-compose  -f "C:\Source\Source_New\docker-compose.yml" -f "C:\Source\Source_New\docker-compose.override.yml" -f "C:\Source\Source_New\obj\Docker\docker-compose.vs.debug.g.yml" -p dockercompose4844363816882955001 up -d --build --force-recreate --remove-orphans

    I'm able to run the application from this docker container. I can do an exec, and see the files inside this container:

    > docker exec -it 62f2461e5a0c cmd

    > dir -- retruns all the source files and directories

    However to port the container, i pushed it into docker registry and when i pull/run the application, it does not retain the source files.

    > docker run -d devintdocker/xyzapp.ui.webwindows_01:dev xyzui

    now when i try to see the files >docker exec -it 62f2461e5a0c cmd

    I do not see the source files. I am new to docker, so I see i'm missing something. Any help would be grateful



    Wednesday, March 21, 2018 4:08 AM

All replies

  • Don't use Visual Studio for anything related to docker release cycle due to issues you mentioned. It hides from you how docker containers are actually working. In this specific case when you debug your container FS actually just maps to files on your host, it does not actually build proper container for debugging purposes. You can mess around with VS and try to make it work or just create proper dockerfile yourself by hand, it's worth investing in learning how this part works since you'd need it for CI/CD down the road anyway. I think VS is too smart for it's own good, VS Code is much better choice nowdays.
    Wednesday, March 21, 2018 2:23 PM
  • VS appends the tag :dev as a reminder that the image is good only for development, you should not publish it, VS does not copy the source files inside the container to faster the development cycle. If you want to publish your image to a registry then you should build your containers from the cli.
    • Edited by Spartaco73 Tuesday, July 17, 2018 1:50 PM
    Tuesday, July 17, 2018 1:48 PM