Docker Deployment mit Synology NAS

Introduction
Synology NAS is a powerful NAS and it can support docker, so we can do a lot of things with it. If you want to deploy your asp.net core 2.0 to synology, that will be easy with docker.

Using the code
I will use visual studio 2017 for Windows for create the asp.net core 2.0 project.

  1. Create a new asp.net core 2.0 mvc project and name with “HelloWorld”

  2. 1.We need to go to the project folder and run below command for release the project:

  3. dotnet publish -c Release
    After that you will get the release file in your project bin folder : /bin/Release/netcoreapp2.0/publish/

  4. Copy all of the /bin/Release/netcoreapp2.0/publish/ files to your nas driver, for example: /volume1/web/asp_net_core/helloworld
    Install the asp.net core 2.0 image in docker, you can use “microsoft/aspnetcore“, and select 2.0.5 version:

  5. Create a file name “Dockerfile” without file extension. It is a kind of batch file with Docker commands. The file is needed during the image build process. You can create the file with any text editor you like. Save the file in your project folder. for example: /volume1/web/asp_net_core/helloworld . Please find below content of this file:

FROM microsoft/aspnetcore:2.0.0
COPY . /app
WORKDIR /app
ENV ASPNETCORE_URLS http://*:7500
EXPOSE 7500
ENTRYPOINT ["dotnet", "HelloWorld.dll"]

The Dockerfile execute several important steps :

microsoft/aspnetcore:2.0.5 will be used for the helloword image.
Sets the HelloWorld files location.
Sets application IP port.
Sets application entry point.

  1. Login your nas with ssh and go to your project folder and run below command for create the docker image:

  2. docker build -t helloworld .