Problem statement
Docker 1.12.0 and 1.13.0 introduce new syntaxes for:
- Mount specifications (
docker run --mount and docker service create --mount)
- Port specifications (
docker service create --port)
- Secret specifications (
docker service create --secret)
This raises several questions regarding consistency:
- What are the guidelines in terms of short syntax ("porcelain") versus long syntax ("plumbing")?
- How many flags should be exposed: one for porcelain and one for plumbing, or a single one with two possible syntaxes?
- Where those flags overlap, do they use the same naming scheme for long syntax option names?
Current state
| Area |
Mounts |
Ports |
Secrets |
| Syntax |
Short |
/src:/dest:rw |
80:8080/tcp |
secret_name |
| Long |
src=/src,dst=/dest,readonly=true |
target=80,published=8080,protocol=tcp |
source=secret_name,target=alias |
| Flags |
Short |
-v, --volume |
-p, --publish |
--secret |
| Long |
--mount |
--port |
--secret |
| Named options |
- type
- src, source
- dst, destination, target
- readonly, ro
- bind-propagation
- volume-driver
- volume-label
- volume-nocopy
- volume-opt
|
- target
- published
- protocol
- mode
|
- source
- target
- uid
- gid
- mode
|
What we can see from the table above is that:
- Some areas have a same flag support the short and long syntax.
- Some areas have overlapping named options, but not necessarily the same short versions.
- Some areas have overlapping named options, but not necessarily the same semantic (to be verified).
Proposal
The proposal is to burn it all homogenize according to well defined guidelines that we can reuse in the future for every feature with the same requirement. What follows is an attempt at defining such guidelines.
All features which require both a rich way to express complex things in a non-ambiguous manner, while preserving a nice "porcelain" syntax for the 80% use case should:
- Use the same flag for both the short and long syntax.
- The long syntax should be a comma separated list of
arg=value specifications (e.g., arg1=val1,arg2=val2).
- The short syntax should be a separated list of values (NOTE: separator TBD, although
--publish and --volume use : today), which defines positional arguments that map directly to an expanded long term equivalent. For example, given the order arg1, arg2, arg3, the short syntax val1:val2 is equivalent to the long form arg1=val1,arg2=val2. This is inspired by the way Python function invocation syntax deals with optional and keyword-only arguments.
- Wherever possible, consistency of named arguments in the long form across different features should be enforced, including in any short term aliases that those named arguments can take.
What it means for 1.13.0
If we agree to move forward with this, then we need to review the current set of flags and act accordingly:
References
Ping @joaofnfernandes @aluzzardi @thaJeztah @mstanleyjones @vieux @dhiltgen @ehazlett @dnephin 🌵
Problem statement
Docker 1.12.0 and 1.13.0 introduce new syntaxes for:
docker run --mountanddocker service create --mount)docker service create --port)docker service create --secret)This raises several questions regarding consistency:
Current state
/src:/dest:rw80:8080/tcpsecret_namesrc=/src,dst=/dest,readonly=truetarget=80,published=8080,protocol=tcpsource=secret_name,target=alias-v, --volume-p, --publish--secret--mount--port--secretWhat we can see from the table above is that:
Proposal
The proposal is to
burn it allhomogenize according to well defined guidelines that we can reuse in the future for every feature with the same requirement. What follows is an attempt at defining such guidelines.All features which require both a rich way to express complex things in a non-ambiguous manner, while preserving a nice "porcelain" syntax for the 80% use case should:
arg=valuespecifications (e.g.,arg1=val1,arg2=val2).--publishand--volumeuse:today), which defines positional arguments that map directly to an expanded long term equivalent. For example, given the orderarg1,arg2,arg3, the short syntaxval1:val2is equivalent to the long formarg1=val1,arg2=val2. This is inspired by the way Python function invocation syntax deals with optional and keyword-only arguments.What it means for 1.13.0
If we agree to move forward with this, then we need to review the current set of flags and act accordingly:
--portflag should likely disappear in favor of--publish, ensuring that the short form maps cleanly to the long form. Remove --port and update --publish for services to support syntaxes #28943-vsyntax is likely already too overloaded to map cleanly to the long-syntax equivalent introduced by mount, and we might need to drop support for--mountinrununtil we can figure this out.sourcesupports in mounts).References
--mounttodocker run#26825 - Add--mountflag todocker createanddocker runPublishModein services using the--portoption in docker service createPing @joaofnfernandes @aluzzardi @thaJeztah @mstanleyjones @vieux @dhiltgen @ehazlett @dnephin 🌵