Skip to content

Commit e10405e

Browse files
committed
docs: Add Docker Hub authentication example
1 parent 88633f5 commit e10405e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Sources/swift-container-plugin/Documentation.docc/authentication.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,34 @@ Configure the plugin to authenticate to your container registry.
66

77
Many container registries require authentication in order to push images, or even pull them.
88
The plugin reads your registry credentials from a `.netrc` file in your home directory.
9-
Add a record into the `.netrc` file for each registry you use, the plugin uses the authentication by the registry you choose.
9+
Add a record into the `.netrc` file for each registry you use.
10+
The plugin chooses the correct record based on the hostname of the registry's authentication server.
11+
12+
> For some registries, such as Docker Hub [(see example)](<doc:#Docker-Hub>), the authentication server hostname might not be the same as the registry hostname you use when pushing and pulling images.
1013
1114
The following example shows placeholder values for the registry `registry.example.com`:
1215

1316
```
1417
machine registry.example.com
1518
login myuser
1619
password mypassword
17-
```
20+
```
21+
22+
The following examples show how to set up the plugin for some popular registry providers.
23+
24+
### Docker Hub
25+
26+
> Don't use your Docker Hub account password to push and pull images.
27+
> Personal Access Tokens have restricted privileges and you can create a separate token for each integration you use, which you can monitor independently and revoke at any time.
28+
29+
1. Log into Docker Hub and [generate a Personal Access Token](https://docs.docker.com/security/for-developers/access-tokens/) for Swift Container Plugin.
30+
31+
2. **Set the token's access permissions to *Read & Write*.**
32+
33+
3. Copy the token and add it, together with your Docker ID, to your `.netrc` file under the machine name `auth.docker.io`:
34+
35+
```
36+
machine auth.docker.io
37+
login mydockerid
38+
password dckr_pat_B3FwrU...
39+
```

0 commit comments

Comments
 (0)