I have run through the boot2docker virtual machine setup tutorial in the docker toolbox https://www.docker.com/toolbox.
Using window 10 as my base, I managed to get virtualbox running from kitematic with Linux default 4.0.9-boot2docker
When I start trying to run apt-get or yum to install things like NODE.JS or ASPNET I'm told that the files aren't found.
The end goal is to be able to run my aspnet docker images on my local environment.
Do I need to install aspnet, node, etc... on my docker server before I can start running aspnet docker images? If yes, how do I install them in the version of linux that has no apt-get or yum?
edit - note it is the ASPNET core documentation that seems to suggest I need to install things on the docker server. https://dotnet.readthedocs.org/en/latest/getting-started/installing-core-linux.html perhaps I can docker-build within the windows environment and docker-run from the linux VM without actually installing anything other than my docker image?
With docker you can focus on using application, not installation.
you needn't waste time on application installation that you can pull the image directly to get node.js or aspnet environments work in minutes.
So answer your question, you can have these environments ready via pull command:
docker pull node
docker pull microsoft/aspnet
Related
In a project im working on, we are upgrading our Episerver CMS website from CMS11 (.net framework) to Optimizely CMS12 (.Net core) for a customer.
To run IIS Express using CLI (to not have the need to run the application from VS/Rider) and start NPM develop, we have written this .bat script.
#ECHO OFF
ECHO starting site
start iisexpress /config:.vs\*PROJECT_NAME*\config\applicationhost.config /siteid:2
cd %~dp0\src\Site
start npm run develop
As a result of upgrading from framework to core, we are now configuring the project through appsettings.json instead of applicationhost.config (XML), where we define which site bindings to be launched from (siteid:2).
I've been looking for a way to do the same through bindings in .json, with no luck. Does anyone have any ideas for a solution?
I would recommend using Kestrel instead of IIS Express locally and simply start the site with: dotnet run
You can also use dotnet watch to automatically rebuild/restart the site when source code files change.
https://learn.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-7.0&tabs=windows#run-the-app
I am trying to build a web deploy package on the .net core sdk docker image to be used to deploy to a windows server running iis (the deployment being done on a seperate windows vm). This is the command I am running (this can also be done via the publish UI in visual studio):
dotnet publish src/SpaceForce.sln -c release -o out -p:WebPublishMethod=Package;PackageAsSingleFile=True;DesktopBuildPackageLocation="../Package/SpaceForce.WebAPI.zip"
On Windows this produces a folder with the following files and then when i'm ready to deploy, i just run the cmd file:
SpaceForce.WebAPI.deploy.cmd
SpaceForce.WebAPI.deploy-readme.txt
SpaceForce.WebAPI.Parameters.xml
SpaceForce.WebAPI.SetParameters.xml
SpaceForce.WebAPI.SourceManifest.xml
SpaceForce.WebAPI.zip
but on Linux (.net core sdk docker image) it produces the following error:
/usr/share/dotnet/sdk/3.1.300/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(97,5): error MSB6004: The specified task executable location "%ProgramW6432%/IIS/Microsoft Web Deploy V3/msdeploy.exe" is invalid. [/home/osboxes/src/spaceforce/src/SpaceForce.WebAPI/SpaceForce.WebAPI.csproj]
on this page, it has this note but i'm not sure if this applies in my case:
The dotnet msbuild command is a cross-platform command and can compile ASP.NET Core apps on macOS and Linux. However, MSBuild on macOS and Linux isn't capable of deploying an app to Azure or other MSDeploy endpoints.
If i can build on linux, i am happy to run the cmd file on a windows box for deployment. Is it possible to build this package on linux?
As you quoted, MSDeploy is a Windows-only thing. Using the WebPublishMethod switch tries to run "%ProgramW6432%/IIS/Microsoft Web Deploy V3/msdeploy.exe", which is obviously not present in the linux container.
To publish an app from a linux environment to an IIS server you have to publish the app without the WebDeploy specific features and then send the published files to the IIS server. On the server you configure an app with a set physical path and move the published files into that path.
To get the files from the docker image you have to create a temporary container and copy the files
# Dockerfile
RUN dotnet publish src/SpaceForce.sln -c Release -f netcoreapp3.1 -o /out
# bash script to get the publish dir from the image
imageId=$(docker create <IMAGE_NAME>)
docker cp $imageId:/out/ <HOST_DIR>
docker rm $imageId
This article should get you started.
Hope this helps a litte đ
So this is a C#-based .Net WebApp for a client on an Azure deployment on their network.
Testing locally, I can do dotnet run and test on http://localhost:5000 fine, but in the final environment, it'll need to be served by IIS. I believe dotnet run (Kestrel) and IIS have a way of talking to each other (there is a method called something like .useIISIntegration I believe).
But I'd like to skip any deployment script that requires I dotnet run to start the application if possible, but let IIS handle all of that. Once deployed, is dotnet run absolutely necessary? How does IIS handle it directly, if possible?
I guess that for your purpose you can simply:
run dotnet publish
create an application in IIS against the program
create an application pool and start it.
Don't forget to install the SDK/Hosting bundle in the destination server otherwise IIS will not be able to run it.
I'm getting an error trying to use the Docker functionality with my .NET core 2.0 project. I've been getting an error message saying
Visual Studio Container Tools requires Docker to be running before
building, debugging or running a containerized project. For more info,
please see: http://aka.ms/DockerToolsTroubleshooting
I followed the link, and upon realizing I have Windows 10 Home x64, and had to install Docker Toolbox, instead of Docker For Windows. Now it installed this executable called
Docker Quickstart Terminal
Is this the way one is supposed to start up that docker services? I have tried running this executable, and it seems to be working. My containers are running, but the error for Visual Studio Container Tools still persists.
What am I missing? Is having a version of windows higher than Home required in order to use the Docker Container Support within Visual Studio 2017?
UPDATE:
I tried to follow Quetzcoatl's suggestion, and I am still getting the same error within visual studio about those tools. Here is what I ran in the Docker Quick Start Terminal. I tried building the project after Visual Studio successfully opened the project, and was still getting the aforementioned error regarding the container tools.
My devenv.exe file is located at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe
and my solution file is located at
D:\Development\Visual Studio\Musify2\Musify2\Musify2.sln
UPDATE 2:
I ran some of the suggested commands to try in the docker quickstart terminal and here were the results of those commands quetz
With Docker Toolbox that's a little tricky, but actually the core-2.0 has nothing to do here. It's all about docker, docker-toolbox, and VS.
First of all:
Is this the way one is supposed to start up that docker services? I have tried running this executable, and it seems to be working.
Yes it is. If docker machine/services are running - that's good!
Now, you have to realize that in docker, typically, the information about how/where the docker is running is kept in environment variables. The quickstart script not only starts the docker-machine for you and checks some basic things, it also sets up a couple of environmental variables so that later all commands like docker, docker-compose etc know where to look for the docker virtual machine. In your/our case that information mainly consists of an IP of the VM and a port number that Docker listens on.
.. and your Visual Studio has no knowledge of that, because, I bet on that, you have ran the VisualStudio from StartMenu or from Desktop icon or by double-clicking on a solution file, so it had no chance of getting the environmental variables from quickstart console.
The solution is quite simple: make sure that VS gets that information. That is, make sure it gets that environmental variables, and make sure that it gets the fresh state of them, because the IP/port may fluctuate sometimes. So don't just copy them to your OS settings, because nothing will ever automagically refresh them..
The simplest way I found is to just close Visual Studio, run docker toolbox quickstart console, then run the VisualStudio from within that console, for example, for my VS2017 Community Edition:
Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
(.......snip..........)
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
Start interactive shell
quetzalcoatl#LAP049 MINGW32 ~
$ /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/Community/Common7/IDE/devenv.exe C:\\PATH\\TO\\MY\\SOLUTION.sln
The path is pretty long to write, even with TAB-completion, so usually make a tiny .sh script to run that for me.
BTW! Notice that the path to DEVENV must be unix-like (/c/Program\ Files...), because the mingw shell has to understand that, while the path to SOLUTION must be a normal windows path (c:\projects\foo\bar\..) because VisualStudio will try to read that after starting up.
This is what I did to get vs 2017 working on windows 10 home with docker-toolbox. You follow this and i guarantee it will work. Note this only applies to windows 10 home which doesnât support native docker for windows application:
Install docker-toolbox on w10 home
Run docker QuickStart terminal once to create the docker-machine. It takes a while. So be patient while it assigns the IP address and other things
Once itâs done it will show you a command prompt. Type âdocker-machine ip defaultâ. Note down the ip address as youâre gonna need it later
Close the QuickStart terminal window. That was just to initialize the boot2docker.iso image of a tiny Ubuntu linux server into virtualbox app (aka docker-machine aka default vm). If youâre not familiar with virtualization technology or oracle virtualbox stop reading and read up on them first and then start over. But if you do then gladly continue
As I mentioned that your docker-machine instance is a Linux vm and therefore itâs obvious that you can only open projects built using .net core technology. Unfortunately for full .net framework youâll either need to run Windows containers which are only available on windows 10 pro or build your own windows nano server or 2016 server vm on virtualbox and then use and follow steps for native docker for windows on dockers website. From here on the remainder of this answer will be helpful to those wanting to run core projects on Linux vm / docker-machine only
Open windows power shell in administrator mode and type âdocker-machine lsâ to confirm that default vm is running. Can also do âdocker-machine status defaultâ and it should return ârunningâ
Now open virtualbox application which is running your default vm and click on settings. Open âshared drivesâ tab where you need to make sure âc:\Usersâ folder on the host machine is mapped/mounted as âc/Usersâ folder in the vm. Note that this step is super important and missing it will cause a lot of trouble getting it to work successfully
Also a quick note that your solution/project/codebase MUST be saved under âc:\Users\â for it to work correctly. This is if you want to use it OOTB. I didnât wanna waste time trying to mount a folder outside the permitted path. But if youâre the adventurous kind, please, by all means try to figure it out and let us know how you did
Now as Quetzalcoatl correctly mentioned vs needs to know about this docker-machine. The only way that happens is if the environment variables are set. Therefore go ahead and run this command âdocker-machine env default | Invoke-Expressionâ in the powershell window. This is the magic sauce getting vs to behave nicely with docker-machine
Go ahead and open vs normally either by dbl clicking your project solution or creating a new project/solution. In Powershell use the 'start' command to open your existing vs solution or a new vs instance. Pro-tip: if you create a new solution DO NOT select the option of Linux docker at the time of picking the project template type. You can totally add docker support once your solution is all setup and ready to go. Matter of fact leave it unchecked and let vs create your solution. This way youâll get a chance to build and run your solution in IIS Express or Self-hosted modes to see if your core2.0 even works properly
Once satisfied that everything worked and you saw the OOTB homepage now itâs time to add docker support by rt clicking on your project, hovering over Add and then clicking on âAdd Docker Supportâ. This will create a new docker project (.dcproj) and add a bunch of docker related files
Now Iâm not gonna go into the nitty gritty of docker here however youâll notice that your project is no longer the startup and the newly created docker project is. Thatâs perfectly normal and intended behavior. It means youâre setup and ready to fire up your app using docker containers. So go ahead and click on the âDockerâ button to see your hard work finally pay off. Again be patient as it takes a while to build images and spin up containers but once itâs done the vs will start and attach the debugger
Here youâll once again be disappointed and feel worthless because when the browser opens a new window or tab thereâll be a page unreachable error. The reason is the browser address points to localhost which is not the web server anymore. Your âweb serverâ now is your docker container and therefore youâll need to replace localhost with the IP address you retrieved above. Port number remains as it is. Once you submit the page youâll be relieved and ecstatic to see the home page/route work. This should also enable debugging in vs. if for some reason it doesnât then you may need to delete a folder called .vsdbg in c:\Users\ folder and rerun the application.
Scenario
I have a server, that has NO Visual Studio Installed. It literally has a normal command prompt and nothing installed yet. We don't want to install anything (except the .Net framework which we have already done). We just want to install a bunch of C# Windows Services that we have written.
So far
I have been installing and running the windows service on my local machine using a "setup and deploy" project that I built into the application, which I could then use to install the service locally.
Question
How can I install the service on the server?
I imagine it can be done from the command prompt only, but what else do I need? - If anything? and where do I put the files that I want to install BEFORE I install them?
I imagine I will have to compile the application on my local machine in Visual Studio, then copy it over to the server, and then run an install utility to install it on the server?
Any help would be greatly appreciated.
according to this thread you need to run
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe
(replace c:\windows with your windows path)
Your server has a sc.exe (service control) command which allows you to install, uninstall, start, stop and configure services - no Visual Studio bits needed.
Run sc.exe -? at a command prompt to get a listing of all available options
I add code similar to the one in this article to my services:
http://www.codeproject.com/KB/dotnet/WinSvcSelfInstaller.aspx
Then I can install/uninstall them just by typing ServiceName -i or ServiceName -u at the command prompt. Makes it easier if it'll be installed by people who don't know .Net.