GithubHelp home page GithubHelp logo

dotnet-hellodocker's Introduction

Getting Started with .NET Core and Docker

This short tutorial, assumes that you have Docker and Docker Compose installed and configured. The easiest way to get them is through Docker Toolbox or the new Docker Beta for Mac and Windows

If you are wondering what is .NET Core , it's a new set of runtime, library and compiler components for creating web applications and services that run on Windows, Linux and Mac. Moreover, it is fully open source!

If you want to jump in and look at the C# code in the dotnetapp folder. It's a console app, that tries to connect to a PostgreSQL database, init a table, just to persist a greeting, basically, the simple text "Hello Docker" : )

The complete definition of the application components, can be found in "Docker style" in the docker-compose.yml file:

version: '2'

services:
  app:
    build: dotnetapp/
    links:
      - db
  db:
    image: postgres
  • our .NET sample app
  • ... a PostgreSQL database, based on the latest official Docker Image

To run the application, you need to:

  1. open a terminal, configured with the right DOCKER_HOST env

  2. change the working dir to the root of this repo

  3. ...execute the following command:

docker-compose up -d

If you don't have the Postgres and microsoft/dotnet Docker images, the client will first pull those base images and then builds the dotnetapp, as described in the Dockerfile. If everything went well, Docker Compose, first try to run the database and then the dependent console app:

...
Successfully built 345ed606caa8
WARNING: Image for service app was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating dotnethellodocker_db_1
Creating dotnethellodocker_app_1

Finally, you can check if the console app has been executed correctly, with the following command:

docker-compose logs app
Attaching to dotnethellodocker_app_1
app_1  | Project dotnetapp (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
app_1  | Compiling dotnetapp for .NETCoreApp,Version=v1.0
app_1  | 
app_1  | Compilation succeeded.
app_1  |     0 Warning(s)
app_1  |     0 Error(s)
app_1  | 
app_1  | Time elapsed 00:00:05.9834689
app_1  |  
app_1  | 
app_1  | Hello Docker

Hello Docker : )

dotnet-hellodocker's People

Watchers

Jimmy Yen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.