Reputation: 15
can someone tell me whats the difference between -
and --
. For example, in this command:
docker run --name some-name -e MYSQL_ROOT_PASSWORD=some_password mysql
I understand that I am running a docker container with mysql as image, with the name some-name and the password some_password. What I do not get is why I use --
for the name parameter and -
for the password parameter.
Upvotes: 0
Views: 186
Reputation: 369594
What does “--” and “-” mean on any Unix Shell?
--
and -
have no meaning in the shell.
These are simply parameters for the docker
command.
If you want to know what meaning they have for the docker
command, you will have to look them up in man docker
.
There is absolutely no difference between --name
, -e
, foo
, or --!--!--!--
. They are all simply parameter names, the -
is simply as much part of the name as the n
or the e
.
--name
is the name of a parameter, -e
is the name of a parameter, run
is the name of a parameter.
What I do not get is why I use
--
for the name parameter and-
for the password parameter.
The short answer is: because that's what the author of the docker
command chose to call those parameters.
The slightly longer answer is that there are some conventions that some commands follow to some degree. On particular, docker
seems to follow these three very common conventions:
iproute2
and git
, which have a single "master" command whose first parameter is the name of a "subcommand" (which then can have even more subcommands), for example: ip route
, ip addr add
, git commit
, git status
, docker run
.-
. Multiple consecutive options can be combined. Examples: mkdir -p
, ls -la
.--
. Example: ls --color
But I'd like to repeat, because it is very important to understand: this has nothing to do with the shell. These options are processed by docker
and docker
alone. The options would be exactly the same if you called docker
from the Windows command line or from Python: no Unix shell in sight anywhere.
Upvotes: 1
Reputation: 198476
By POSIX standard, options are letters preceded by a single dash. They can be combined; e.g. ls -l -a
is equivalent to ls -la
.
By GNU convention, long options are preceded by two dashes. Obviously, you can't combine them like normal options, but they are more readable.
Most options will have both forms; for example, most programs recognise -h
and --help
as equivalents.
Upvotes: 1
Reputation: 2927
This is an arbitrary convention and not all programs follow it, but usually - precedes a single-letter argument and -- precedes a full-or-multiple-word argument.
Upvotes: 1