7

I am running Windows 10 pro, docker installed and linux containers.

With Visual Studio 2019, I created a basic .net core web api app, and enabled docker support(linux).

I built the solution, and in the output window (View -> Output or Ctrl + Alt + O) I selected "Container Tools" in the Show Output From drop down. Scroll till the end(see the scroll bar in the below image) and you see the entry point option to the docker run command as follows.

--entrypoint tail webapp:dev -f /dev/null

The entire docker run command for your ref is as follows.

docker run -dt -v "C:\Users\MyUserName\vsdbg\vs2017u5:/remote_debugger:rw" -v "D:\Trials\Docker\VsDocker\src\WebApp:/app" -v "D:\Trials\Docker\VsDocker\src:/src" -v "C:\Users\UserName\.nuget\packages\:/root/.nuget/fallbackpackages" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "ASPNETCORE_ENVIRONMENT=Development" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages" -P --name WebApp --entrypoint tail webapp:dev -f /dev/null 

So my question is what is this "tail". I saw two so questions(this and this) but could not get much. Also from here, tail seems to be a linux command(and I am running a linux container) but what does it do here?

Please enlighten me.

enter image description here

VivekDev
  • 20,868
  • 27
  • 132
  • 202

1 Answers1

10

Entrypoint is the binary that is being executed.
Example: --entrypoint=bash --entrypoint=helm like this.
The tail linux utility displays the contents of file or, by default, its standard input, to the standard output /dev/null.
/dev/null redirects the command standard output to the null device, which is a special device which discards the information written to it. So when you run a tail -f /dev/null in a terminal it prints nothing.

If you would like to keep your container running in detached mode, you need to run something in the foreground. An easy way to do this is to tail the /dev/null device as the CMD or ENTRYPOINT command of your Docker image.

vijay v
  • 1,888
  • 1
  • 12
  • 19
  • You mean to say its same as '-it', in the command docker run --rm -it webapp:dev – VivekDev Mar 29 '20 at 07:54
  • `-it` takes you straight inside the container only when you mention the executables in the end of your command. like `docker run -it --rm nginx:stable bash` gets me to a bash tty for further interacting with the container. In your docker run command, you say it to keep running in detached mode with `-d` option. Having entrypoint to `tail -f /dev/null` doesn't shutdown the container. – vijay v Mar 29 '20 at 07:58
  • So, how do we get it to not include this? -- It's keeping my containers alive indefinitely, even after the service's process has ended. – BrainSlugs83 Jun 24 '21 at 22:40
  • Please explain your issue clearly or write a new query. @BrainSlugs83 – vijay v Jun 25 '21 at 09:14