Terminal (bash?) / Docker: logic behind – and —

For three days I am learning to work with Docker.
During this I ran commands like

sudo docker run --rm -ti --net=example --name server ubuntu:14.04 bash 

and

  • Docker CMD with envsubst and tee
  • Kubernetes doesn't pull from private Docker Registry
  • docker: Can't use ls in mount directory
  • How can I tell if docker has frozen?
  • How to create autostart services in Docker container?
  • How to install nvm in a Dockerfile?
  •  nc -lp 1234
    

    I was wondering why I have to use sometimes a - and for other commands a --
    Is there any logic?

    Regarding the topic of my question: I am aware that it is not a good topic. I am sorry for that. This question occurred while working with Docker but I do not know if the - or -- thematic is more a terminal or docker topic.

  • GUI app in Docker not working
  • Where to keep dependencies (large files or directory structures) for use with Docker/Docker-Compose?
  • Docker image is not visible through the Remote Docker API
  • Change Default Docker Image Download Location in Fedora 23
  • How to run headless Firefox profile manager? How run Firefox profile manager in docker?
  • docker login behind proxy on private registry gives TLS handshake timeout
  • 2 Solutions collect form web for “Terminal (bash?) / Docker: logic behind – and —”

    It depends on the command. There are conventions, but none of them are followed universally.

    In the Old Days, options were single letters. If an option took an argument, it could follow the option letter with or without an intervening space (command -x foo or command -xfoo).

    Options that don’t take arguments can be bundled, so command -x -y can be written as command -xy. For many commands, even options that do take arguments can be bundled, with the last specified option taking the argument: command -x -y foo vs. command -xy foo. The nc -lp 1234 in your question is an example of this; l and p are two different options. That could also have been written as nc -l -p 1234.

    Commands from the GNU project can typically accept options either in the traditional short form and in a long form, where the option name is an entire word that can be abbreviated as long as the abbreviation is unique. For example, ls has a -F option to append a / to directory names and so forth. Gnu ls lets this be specified as --classify, or abbreviated as --cl. To avoid ambiguity and for backwards compatibility, old-style single-letter options use a single -, while long-form options use --.

    Finally some commands take options with long names introduced by a single -; the find command is an example of this.

    The only real solution is to read the man page for the specific command you’re running.

    A single dash can be followed by multiple single-character flags. A double dash is followed by a single, multi-character flag.

    in your case

    sudo docker run --rm -ti --net=example --name server ubuntu:14.04 bash
    

    flags:

    rm (multi-character)
    t  (single)
    i  (single)
    net (multi-character)
    name (multi-character)
    

    ,

    nc -lp 1234
    

    flags:

    l (single)
    p (single)
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.