6

I build successfully with dockerfile, but when I try to run a new container from the build image, I get the following error:

What do i have to do for the solution?

Error : /bin/sh: 1: [dotnet,: not found

docker run command:

docker run --rm -it -p 8080:80 furkaandogan/myapp:0.1

Dockerfile:

FROM microsoft/aspnetcore:1.1
ARG source
WORKDIR /app
ENV ASPNETCORE_URLS http://*:80
EXPOSE 80
COPY ./publish/myapp .
ENTRYPOINT ["dotnet", "myapp.dll"]
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • If you have built the image in Visual Studio, this link could help: http://stackoverflow.com/a/43720639/5112433 – Ilya Chumakov May 19 '17 at 20:26
  • Please do not edit solutions into the problems -- doing so makes it impossible for the community to review a proposed solution (even the OP's proposed solution) distinct from the problem itself. The appropriate way to share a solution is with the "add an answer" link, as you've done. – Charles Duffy Jan 10 '18 at 17:08

4 Answers4

6

I faced similar issue. In my case the problem was in the entry point statement in Dockerfile. I was missing a comma between two parameters "dotnet" and "url for dll".

Before:

CMD ["dotnet" "url to dll"]

After fix applied:

CMD ["dotnet", "url for dll"]
Rohlik
  • 1,286
  • 19
  • 28
yvinap
  • 91
  • 1
  • 6
2

There is something on your entrypoint line of the Dockerfile to trigger docker into seeing it as invalid json and it's falling back to shell execution of the string instead. It looks correct in what you pasted, so I'd check for characters like smart quotes or perhaps a Windows newline at the end of the string.

BMitch
  • 231,797
  • 42
  • 475
  • 450
1

The problem is that the docker ignore file does not allow the copy address

I solved the problem by adding the address to the docker ignore file or using the allowed file address

Old dockerignore config

*
!obj/Docker/publish/*
!obj/Docker/empty/

new dockerignore config

  *
    !obj/Docker/publish/*
    !obj/Docker/empty/
    !publish/myapp
  • 1
    I would be rather surprised if you could reproduce `Error : /bin/sh: 1: [dotnet,: not found` by reverting back to your prior .dockerignore file, but no doubt it was causing issues that would result in a different error. – BMitch May 20 '17 at 20:38
  • this is actually the best answer i've got out there. because im checking my logs on jenkins and the last i've got this error was actually when i added a gitignore to this project. – Muzi Jack Jun 07 '19 at 13:48
  • but putting that gitconfig code above, did not change anything from my builds im still getting the same error – Muzi Jack Jun 07 '19 at 13:55
1

Above answers are quite clear, but I followed above and changed my CMD [ 'node', 'app.mjs' ] to CMD [ "node", "app.mjs" ], made sure I added a comma, same thing still happened.

After I mess around for a little while, I started to think, maybe I need to rebuild the docker file again, so I did docker build . again. Boom, it works this time!

Such a rookie's mistake! just like when I made changes to Java repo but I don't rebuild the java repo so error still happens.

stoneshishang
  • 433
  • 4
  • 11