All Projects → DaniJG → DockNetFiddle

DaniJG / DockNetFiddle

Licence: MIT License
JSFiddle but with Docker and .NET Core

Programming Languages

C#
18002 projects
HTML
75241 projects
smalltalk
420 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

DockNetFiddle

This repo contains the code for the article Building DockNetFiddle using Docker and .NET Core published in the DotNetCurry magazine.

It is the full source code of the proposed DockNetFiddle site, an ASP.Net Core application built with the aim of learning about docker and .Net Core.

DockNetFiddle is a simple site where users can enter minimum but complete .Net Core applications (providing the contents for the files program.cs and project.json ) which will be then executed inside a docker container. The results of the program execution will be send back and displayed to the users. In the end is a very simple version of the real .NetFiddle site.

The project uses 2 containers, one running the ASP.Net Core application and a separated one which will run the programs entered by the user.

VS2015 vs VS2017

The project was originaly built in VS2015 and used the "old" .Net Core project style based on the project.json file. Since then, VS2017 has been released and .Net Core has moved back to csproj and its XML based project file.

  • If you want to use VS2015, stay on the master branch. The site will let users write .Net Core console applications with a project.json file.
  • If you want to try VS2017, use the VS2017-csproj branch. The site will let users write .Net Core console applications with a project.csproj file.
  • If all you want to do is docker-compose up, you can try either branch :). The dockerfiles in master are locked to the old project.json base images while the dockerfiles in VS2017-csproj use the latest .net core images.

Instructions

  1. clone the repo in a new folder
  2. cd into src/DockNetFiddle
  3. run docker-compose up. This will generate the docker images and start new containers
  4. fire up a browser and open http://localhost:8080 (replace localhost with the ip of your docker host or docker VM if using docker toolbox in win7/8)
  5. the site home page should load: alt
  6. press Run to execute the code
  7. stop the containers with Ctrl+C (console will be attached to both containers, so you will need to press it twice)
  8. optionally remove the containers with docker-compose down

Running in the background

If you run docker-compose up your console gets attached to both containers (making the output hard to follow) and you will stop them if you stop the console.

You can also run them in the background and attach/detach the console when needed

  1. run docker-compose up -d
  2. attach to one of the containers with docker attach webapp or docker attach coderunner. You will see the output in your console (although coderunner will be in its infine loop without printing anything). Press Ctrl+C to detach and leave the container in the background.
  3. attach an interactive shell on one of the containers as in docker exec -it coderunner /bin/bash. You will be then in a new terminal inside that container. Enter exit when finished, the container will keep running in the background.
  4. stop and remove the containers with docker-compose down (Or manually send docker stop and docker rm commands)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].