How To Install Latest Nuget In Dockerfile For Windows

 

Hello everybody,

today I want to write few words about how to instal latest Nuget into Windows docker container. For this purpose you can use following commands:

RUN mkdir c:\Nuget
RUN Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/v4.1.0/nuget.exe' -OutFile 'c:\Nuget\nuget.exe'; \
$env:PATH = $env:PATH + 'c:\Nuget\;c:\Nuget'; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

No Comments

Add a Comment
 

 

How To Execute Some Process In Dockerfile

 

Hello everybody,

today I want to share another piece of code, that proved to be helpful for me in creating docker containers.

Here it is:

Start-Process c:\sdksetup.exe -ArgumentList '/Quiet /NoRestart' -Wait; \

First time when I seen it I was sceptical. Why I should use Start-Process instead of just running application? The answer is simple: because quite often installers just execute some processes and give control to powershell in asyncronous way. And if other parts of your docker image are dependable from your sdksetup.exe, then you'll not get needed container.

For example you can install Dot net 4.6.2 package in the following way:

RUN Invoke-WebRequest 'https://download.microsoft.com/download/E/F/D/EFD52638-B804-4865-BB57-47F4B9C80269/NDP462-DevPack-KB3151934-ENU.exe' -OutFile 'NDP462-DevPack-KB3151934-ENU.exe';\
        Start-Process 'c:\NDP462-DevPack-KB3151934-ENU.exe' -ArgumentList '/Quiet /NoRestart' -Wait; \
        Remove-Item 'c:\NDP462-DevPack-KB3151934-ENU.exe'

Another question that you can ask, why not to use chocolatey? Hm. You can try to achieve it with chocolatey and you will find that for now chocolatey can't install Dot net 4.6.2 package for some reasons mentioned in log file.

No Comments

 

Add a Comment
 

 

How To Copy Folder In Dockerfile

 

Hello everybody,

recently I had following issue:

copy folder dotnet-dev-win-x64.1.0.1 into c:\Program Files\Dotnet in container. After different dancing and triings I've found following command that worked:

COPY ["dotnet-dev-win-x64.1.0.1", "c:/Program Files/dotnet"]

No Comments

 

Add a Comment
 

 

How To Add To Docker Image Dot Net Sdk And Other Useful Staff

 

Hello everybody,

today I want to write few rakes of Dockerfile.

First of all I want to document how to install dot net sdk 1.1. It isn't installable by chocolatey, so I had to use following workaround:

RUN Invoke-WebRequest 'https://download.microsoft.com/download/1/1/4/114223DE-0AD6-4B8A-A8FB-164E5862AF6E/dotnet-dev-win-x64.1.0.3.exe' -OutFile dotnetDev.exe
RUN .\dotnetDev.exe /Silent /Full

Another issue, that I faced was installing of Git, or for containers I prefer MinGit. It can be achieved in the following way:

RUN Invoke-WebRequest 'https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/MinGit-2.12.2.2-64-bit.zip' -OutFile MinGit.zip

RUN Expand-Archive c:\MinGit.zip -DestinationPath c:\MinGit; \
$env:PATH = $env:PATH + ';C:\MinGit\cmd\;C:\MinGit\cmd'; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

If you have need for dockerfile to execute powershell (as I like to do) the following command in docker file can be needed:

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

No Comments

Add a Comment
 

 

Working With Dockerfile

 

Hello everybody,

today I want to write a few words about Dockerfile. 

So, as usually for developer it will not be enough just ordinary docker images. Quite often they need to add some more features to docker images. One of the useful ways to organize it can be creating Dockerfile. 

Dockerfile in itself just a text file with instructions. Of course that instructions are docker specific. And it's similar to making program say in C#. While after C# program I need to execute compiler, with Dockerfile I need to execute command docker build. You can consider docker build as compiler from Docker. 

Executed image is a container. 

Dockerfile has build instructions. 

Some docker instructions

FROM - points to basic image. 

MAINTEINER - say who maintains image

RUN - with this command you can point either you need to download something from internet, compile source code, RUN npm install, etc

COPY - copy something into container

ENTRYPOINT - what is main entrypoint of your container. Something that starts container functionality. javatype, nodejs, dnx, etc types of commands

WORKDIR - configure context for where that container is executed

EXPOSE - expose port

ENV - define environment varialbes

VOLUME - define volume and how it is stored in host system

Some samples of instructions:

FROM node - means the following from node build an image, grab node, and add additional layers on top of it

MAINTAINER  yura_zaletsiy@yahoo.com - to whom write an email.

RUN npm install - execute npm install command

EXPOSE 8080 - open port 8080

COPY . /app - copy content of local folder into folder app

After you created your docker file, you can use docker build like tis

docker build -t somename/aspnetcore .

Take not that . in the end is named Build context. It shows where is Dockerfile.

No Comments

Add a Comment