skip to Main Content

enter image description here

This evening, by checking the data, I learned that to make the docker container run in the background, you should add tail - f /dev/null after the command. However, I don’t understand the meaning of each letter in the command tail - f /dev/null. I only know that it can make the docker container run in the background. I want to know the meaning of each letter in the command tail - f /dev/null,Thanks in advance.

2

Answers


  1. There is a typo in your command. Remove the whitespace between – and f then it should work.

    tail is responsible to read the last 10 lines of a file -f parameter means follow all lines which will be added to the file.

    This is the reason why the terminal will stay open.

    /dev/null is a Linux device.

    Login or Signup to reply.
  2. I think you mean tail -f /dev/null

    From man tail:

    DESCRIPTION
           Print the last 10 lines of each FILE to standard output.
    .
    .
    .
    -f, --follow[={name|descriptor}]
              output appended data as the file grows;
    
              an absent option argument means 'descriptor'
    

    /dev/null is a virtual device file that will appear to tail as if it were a "normal" file.

    In plain English, this will make tail keep waiting for new data in /dev/null, but there will never be any since it’s a special type of device (essentially a black hole).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search