Steve0212
Steve0212

Reputation: 712

Deploy Docker to offline PC

I am new to docker and have hit a road block I am having troule figuring out.

Here is my scenario

Current (pre-container)

  1. We do a Visual Studio Online build that outputs an MSI. The build uses the full .Net Framework (we will later go to .Net core).
  2. The MSI is put on a flash drive and installed on an offline (no internet access) computer.
  3. The MSI installs several Windows services that expose web api web services.
  4. Local clients can query those web services.

Desired (containers)

  1. We wish to replace the windows services with docker containers.
  2. The installation still needs to be performed offline (no internet access)
  3. We wish to use docker community edition to avoid cost.
  4. One assumption: the offline computer will have docker installed and will have already downloaded the base image "microsoft/aspnet".

To start figuring this out, I simply created a new ASP.NET Web Application from VS 2017. I chose Web Api and to enable docker support. Great, now I have a container running with a web site / service in it. I next wanted to try to figure out how to deploy the container / image. For reference, here is the default Dockerfile that was created when I created the empty project.

FROM microsoft/aspnet:latest
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .

I first looked at "docker save". My thinking was that I could save the image as a file and use that to deploy the container. However, because I am using the full .net framework, the saved file is 7.7 GB. I understand why it is so large; that image has not only my sample web site in it, but also the microsoft/aspnet image in it too. After some googling, I found references do being able to exclude layers (https://github.com/moby/moby/pull/9304), but it does not appear that "docker save" supports that. Ultimately though, that is what I think I want - to be able to save just my layer to a file.

Am I going down the right path with trying to figure out how to save a layer? We are pretty open on how to accomplish this, but we are not able to deploy a 7.7 GB file for every software update.

Any suggestions on how to do this - especially any that incorporate the VS Online build are greatly appreciated.

Thanks.

Upvotes: 2

Views: 1536

Answers (1)

yamenk
yamenk

Reputation: 51768

The only way to transfer an image offline is to save it into tarball using docker save

As for the size of the image, the solution is to use a smaller aspnet. The one you are using is 7GB large. Thus you need to choose a smaller aspnet image that would be sufficient from the available ones

Another solution is to transfer the source code and build the image on the target machine. In this case, you save the microsoft/aspnet:latest to a tarball and transfer it once to the target machine. Whenever you have new updates in the source, you copy the source and the Dockerfile to the target machine and you build the image there.

Upvotes: 1

Related Questions