Docker dotnet image container do not allow me to rebuild after change - asp.net

I am new to docker, and I am trying to set a container to aspnet development. I just run yo aspnet on a folder and run:
docker run -i -t -p 80:5000 -v "$(pwd):/app" -w "/app" microsoft/dotnet /bin/bash
After that, I run the following commands to prepare to environment:
dotnet restore
dotnet build
dotnet run --server.urls http://*:5000
When I do some change to anything in the directory, even to a cshtml file, the changes do not reflect. If I try to stop the server and rerun it, I receive the error:
/usr/share/dotnet/dotnet compile-csc #/app/obj/Debug/netcoreapp1.0/dotnet-compile.rsp returned Exit Code 1
/app/error CS2012: Cannot open '/app/bin/Debug/netcoreapp1.0/app.dll' for writing -- 'Could not find a part of the path
'/app/bin/Debug/netcoreapp1.0/app.dll'.'
Compilation failed.
I could notice that I cannot delete the app.dll file from the bin folder. When I try to delete it, it gives me the following error:
rm -R bin
rm: cannot remove 'bin/Debug/netcoreapp1.0/app.dll': No such file or directory
But, if I enter the folder, the file is there with 0kb size.
Do you know what am I missing to allow me to rebuild the app without need to restart the container?

Related

Docker run gives "CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)"

I am very new to docker. And I am trying to dockerize a helloworld API.
But when I tried to docker run the image, I got this error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: container
f891d7fc7af6e1183256043e6105fc87e25c6959d9745cc972b42c7b2e6f5a06
encountered an error during CreateProcess: failure in a Windows system
call: The system cannot find the file specified. (0x2) [Event Detail:
Provider: 00000000-0000-0000-0000-000000000000] [Event Detail:
Provider: 00000000-0000-0000-0000-000000000000] [Event Detail:
vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(168)\vmcomputeagent.exe!00007FF683797B25:
(caller: 00007FF68377A312) Exception(4) tid(108) 80070002 The system
cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\ComputeSystemManager_ExecuteProcess\VmHostedContainer_ExecuteProcess]
Provider: 00000000-0000-0000-0000-000000000000] extra info:
{"CommandLine":"dotnet
HelloWorldDocker.dll","WorkingDirectory":"C:\app\bin","Environment":{"COMPLUS_NGenProtectedProcess_FeatureEnabled":"0","ROSLYN_COMPILER_LOCATION":"c:\\RoslynCompilers\\tools"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
I have a simple asp.net api. And I have it published to the same folder ./publish
And here is my docker file
FROM microsoft/aspnet:4.7.1-windowsservercore-1709
WORKDIR /app
COPY ./publish .
WORKDIR bin
RUN ls
ENTRYPOINT ["dotnet", "HelloWorldDocker.dll"]
ls shows that the HelloWorldDocker.dll is in the directory ./bin (app/bin). IDK what is wrong here...
This line COPY ./publish . will copy all publish files into your current work directory. The bin folder that contains your DLL now lives here: /app/bin/{your dll}.
It is not necessary to then change the work dir to bin like you did; instead, you could either leave your work dir alone (stay in /app) and specify your entrypoint as:
ENTRYPOINT ["dotnet", "./bin/HelloWorldDocker.dll"]
-OR-
You could set your WORKDIR to /app/bin and specify your entrypoint as you already did: ENTRYPOINT ["dotnet", "HelloWorldDocker.dll"]
The main thing you need to keep in mind is where the files are in relation to your workdir, which you can manage by changing your workdir as well as copying files, as you did by copying all publish files into /app
this may happen when you are rebuilding the image , in fact when you build a docker image it creates some intermediate containers and images so by deleting these containers and images from the previous build fail it worked for me.
In my case, I was with this error (little similar):
Command: docker run -it henriqueholtz/node-win:16.15.1 cmd
docker: Error response from daemon: container 1edc7d95388e28604239457fd47ced188b968ab825f8da400c8bea84cfbb7ceb encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(174)\vmcomputeagent.exe!00007FF744D6C00A: (caller: 00007FF744D3ECEA) Exception(2) tid(368) 80070002 The system cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\ComputeSystemManager_ExecuteProcess\VmHostedContainer_ExecuteProcess]
Provider: 00000000-0000-0000-0000-000000000000].
How I've fix it?
After some hours trying with no success, I've removed all similar images, pulled the image again (in my case from docker hub), and then it worked.
In the runner config.toml, my runner was configured to use the shell pwsh.
I replaced it with powershell and it worked.
The error comes from the fact that, for whatever reason, pwsh is not available.

ASP.NET Core Project w/ JavaScriptServices in Docker Unable to Launch Node

I am having issues getting a site to run properly inside of a docker container. The container builds fine and runs, however when navigating to a page it fails on loading JavaScript services.
Here is the Dockerfile
FROM microsoft/aspnetcore-build:2.0 AS builder
WORKDIR /app
ADD company_cas.pem /usr/local/share/ca-certificates/company_cas.crt
RUN update-ca-certificates
COPY company_cas.pem ./
RUN npm config set cafile company_cas.pem
# Run NPM install for dependencies
COPY package.json ./
RUN npm install
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=builder /app/out .
ENTRYPOINT ["dotnet", "web.dll"]
I am using the microsoft/aspnetcore-build:2.0 base image, and npm does run so Node is installed to the best of my knowledge.
The output of the failed request is -
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
web | An unhandled exception has occurred: Failed to start Node process. To resolve this:.
web |
web | [1] Ensure that Node.js is installed and can be found in one of the PATH directories.
web | Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
web | Make sure the Node executable is in one of those directories, or update your PATH.
web |
web | [2] See the InnerException for further details of the cause.
web | System.InvalidOperationException: Failed to start Node process. To resolve this:.
web |
web | [1] Ensure that Node.js is installed and can be found in one of the PATH directories.
web | Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
web | Make sure the Node executable is in one of those directories, or update your PATH.
web |
web | [2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception: No such file or directory
Full Error Stack # Pastebin
Is this a matter of setting a new PATH for ASP.NET to find Node? If so, any idea on what that path should be in Docker?
I guess I overlooked the runtime image base container.
Changed to FROM microsoft/aspnetcore-build:2.0 and now I'm good.

AWS beanstalk wordpress

I was trying to setting up my AWS beanstalk by following the implementation guide provided by AWS.
But when I got to the "Launch an Elastic Beanstalk Environment" section, this message appeared which basically said the app is not created.
Here's the message:
[Instance: i-088472611e1ef4405] Command failed on instance. Return
code: 1 Output: ln: failed to create symbolic link
'wp-content/uploads': No such file or directory. container_command
2link in wordpress-beanstalk/.ebextensions/efs-mount.config failed.
For more detail, check /var/log/eb-activity.log using console or EB
CLI.
Does anyone have the same problem or know how to resolve this?
Try changing the efs-mount to read the following, the directory clearly doesn't exist so lets just create it.
container_commands:
1chown:
command: "chown webapp:webapp /wpfiles"
2create:
command: "sudo -u webapp mkdir -p wp-content/uploads"
3link:
command: "sudo -u webapp ln -s /wpfiles wp-content/uploads"
2create will create the directory owned by the webapp user and should let you continue.
I just faced the same issue. I am going to assume deploying via the AWS console. That is how I started.
STEP 1: I checked if there was an actual directory wp-content/uploads in wordpress-beanstalk and there was not. It might get created on the first WP upload So, I created the folder, rezipped the application, and deployed to Beanstalk via the AWS Console.
I still received the same error and moved on to step 2
STEP 2: Run EB DEPLOY from the command line
from my local wordpress-beanstalk directory
eb init
choose region (if you already created your app should be this region)
if you already created application choose that wordpress-beanstalk for example
eb use name of your environment
eb deploy
I am not certain that Step 1 is related to Step 2, but was able to successfully deploy facing the same issue using EB CLI.
This is the mounting error of EFS .
EB is using EFS storage to store the wordpress files .
Please check the no.7 in documentation .
"Modify the configuration files in the .ebextensions folder with the IDs of your default VPC and subnets, and your public IP address."
Please edit the efs-create.config file inside the .ebextension folder.
A bit late here so for anyone else having this issue, it's caused when that directory does not exist. Here are some reasons this might happen:
1). WP has not created it - Check manually that it exists.
2). .gitignore - When a .ebignore file is not present, EB uses your .gitignore instead. This can cause the directory to not be uploaded with the EB deploy command. If this is the case, make a .ebignore, EB will start ignoring the .gitignore
3). Document root - If you have modified the document root, to something like /src you have to modify the efs-mount.config file.
##############################################
#### Do not modify values below this line ####
##############################################
container_commands:
1chown:
command: "chown webapp:webapp /wpfiles"
2link:
command: "sudo -u webapp ln -s /wpfiles src/wp-content/uploads"
Even though the file mentions not to modify it, you have to add your document root path in the 2link entry. Change wp-content/uploads to src/wp-content/uploads (replace src with your document root)
Finally, I would not include a command to automatically make this directory, as that only puts a band-aid on the problem.
Hope this helps

Selecting a Gradle build file from directory above using the command line

I'm building a shell script that does a gradle build and then run my grunt build after it is done and I'm storing this shell script in a subdirectory but the the graddle wrapper is in the root directory of the file. My shell script looks like this
sh .././gradle ../build.gradle clean build
grunt build
So when I call the script from the root directory it looks like this
$ sh gradle fullbuild
It errors out saying that
Execution failed for task ':fullbuild'. > Process 'command 'sh'' finished with non-zero exit value 127
When I do the first command from the script in the sub directory it says
FAILURE: Could not determine which tasks to execute. * What went wrong: Task '../build.gradle' not found in root project 'tools'.
Can I call gradle from a subdirectory and use that directories build.gradle file?
With the -b flag you can indicate which build file to use. Try
sh ../gradle -b ../build.gradle clean build
You could also specify the -p flag instead which indicates which directory is the project dir.

XCode 'Run Script' step to create directory and copy file is failing

I have the following custom script step during my build:
mkdir -p "${CONTENTS_FOLDER_PATH}/Frameworks"
cp "${SRCROOT}/testing.1.dylib" "${CONTENTS_FOLDER_PATH}/Frameworks"
The script runs successfully, but when I check the bundle the Frameworks directory does not exist.
Should not not work as I expect? (Frameworks folder created with the testing.1.dylib in it).
Edit: Added screenshot of the runscript.
How about trying the following:
dst=${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Frameworks
mkdir -p "${dst}"
cp "..." "$dst"
(I found your example and adapted it as above to copy a dylib into the 'Frameworks' folder of my framework).

Resources