mirror of https://github.com/docker/docs.git
The previous instructions fixed situations where the directory
and file didn't exist, but had some issues remaining;
The `>>` _appends_ the content to the file; this would work if the file didn't
exist (before `touch`'ing it) but if there happened to be a file already, it
would append the content to the existing file, resulting in invalid JSON.
e.g. running it twice (which may be accidentally);
```bash
sudo echo '{"allowedOrgs":["myorg"]}' >> "/Library/Application Support/com.docker.docker/registry.json"
sudo echo '{"allowedOrgs":["myorg"]}' >> "/Library/Application Support/com.docker.docker/registry.json"
```
Would result in;
```bash
sudo cat "/Library/Application Support/com.docker.docker/registry.json"
{"allowedOrgs":["myorg"]}
{"allowedOrgs":["myorg"]}
```
(which is invalid JSON)
The `sudo echo` also had some issues; the `sudo` only applied to the `echo`, and
not to the piped output (see https://unix.stackexchange.com/questions/1416/redirecting-stdout-to-a-file-you-dont-have-write-permission-on);
```bash
$ sudo touch "/Library/Application Support/com.docker.docker/registry.json"
$ sudo echo '{"allowedOrgs":["myorg"]}' > "/Library/Application Support/com.docker.docker/registry.json"
bash: /Library/Application Support/com.docker.docker/registry.json: Permission denied
```
Instead, using `tee` to run as privileged process, similar to the approach taken
in
|
||
|---|---|---|
| .. | ||
| analytics | ||
| content | ||
| guides | ||
| landing-page | ||
| api-version-matrix.md | ||
| breadcrumbs.html | ||
| cli.md | ||
| configure-registry-json.md | ||
| deploy.md | ||
| desktop-install.html | ||
| desktop-license-update.md | ||
| desktop-linux-launch.md | ||
| desktop-update.md | ||
| eula-modal.html | ||
| eula.md | ||
| experimental-feature.md | ||
| experimental.md | ||
| footer.html | ||
| github-pr.md | ||
| head.html | ||
| header.html | ||
| install-script.md | ||
| navigation.html | ||
| read_time.html | ||
| registry.md | ||
| sign-up-cta.html | ||
| theme-switch.html | ||
| toc_pure_liquid.html | ||
| upgrade-cta.html | ||