You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Automatic Retries of Failed Sync Tasks, to resolve the network problems (rate limit, etc.) while synchronizing
23
23
- Doesn't rely on Docker daemon or other programs
24
24
25
25
## Usage
26
26
27
27
### GitHub Action
28
28
29
-
You can use [image-sync-action](https://github.com/marketplace/actions/image-sync-action) to try image-syncer online without relying on any physical resources.
29
+
You can use [image-sync-action](https://github.com/marketplace/actions/image-sync-action) to try image-syncer online without paying for any machine resources.
30
30
31
31
### Install image-syncer
32
32
33
33
You can download the latest binary release [here](https://github.com/AliyunContainerService/image-syncer/releases)
34
34
35
35
### Compile Manually
36
36
37
-
```
37
+
```bash
38
38
go get github.com/AliyunContainerService/image-syncer
After v1.2.0, image-syncer supports both YAML and JSON format, and origin config file can be split into "auth" and "images" file. A full list of examples can be found under [example](./example), meanwhile the older version of configuration file is still supported via --config flag.
58
+
Image-syncer supports `--auth` and `--images` flag for passing authentication file and image sync configuration file, both of which supports YAML and JSON format. Seperate authentication information is more flexible to reuse it in different sync missions.
59
+
60
+
> The older version (< v1.2.0) of configuration file is still supported via `--config` flag, you can find the example in [config.yaml](./example/config.yaml) and [config.json](./example/config.json).
60
61
61
62
#### Authentication file
62
63
63
-
Authentication file holds all the authentication information for each registry, the following is an example of `auth.json`
64
-
65
-
```java
66
-
{
67
-
// Authentication fields, each object has a URL as key and a username/password pair as value,
68
-
// if authentication object is not provided for a registry, access to the registry will be anonymous.
69
-
70
-
"quay.io": { // This "registry" or "registry/namespace" string should be the same as registry or registry/namespace used below in "images" field.
71
-
// The format of "registry/namespace" will be more prior matched than "registry"
72
-
"username":"xxx", // Optional, if the value is a string of "${env}" or "$env", image-syncer will try to find the value in environment variables, after v1.3.1
73
-
"password":"xxxxxxxxx", // Optional, if the value is a string of "${env}" or "$env", image-syncer will try to find the value in environment variables, after v1.3.1
74
-
"insecure":true// "insecure" field needs to be true if this registry is a http service, default value is false, version of image-syncer need to be later than v1.0.1 to support this field
75
-
},
76
-
"registry.cn-beijing.aliyuncs.com": {
77
-
"username":"xxx",
78
-
"password":"xxxxxxxxx"
79
-
},
80
-
"docker.io": {
81
-
"username":"xxx",
82
-
"password":"xxxxxxxxxx"
83
-
},
84
-
"quay.io/coreos": { // "registry/namespace" format is supported after v1.0.3 of image-syncer
85
-
"username":"abc",
86
-
"password":"xxxxxxxxx",
87
-
"insecure":true
88
-
}
89
-
}
64
+
Authentication file holds all the authentication information for each registry. For each registry (or namespace), there is a object which contains username and password. For each images sync rule in image sync configuration file, image-syncer will try to find a match in all the authentication information and use the best(longest) fit one. Access will be anonymous if no authentication information is found.
65
+
66
+
You can find the example in [auth.yaml](./example/auth.yaml) and [auth.json](./example/auth.json), here we use [auth.yaml](./example/auth.yaml) for explaination:
67
+
68
+
```yaml
69
+
quay.io: # This "registry" or "registry/namespace" string should be the same as registry or registry/namespace used below in image sync rules. And if an url match multiple objects, the "registry/namespace" string will actually be used.
70
+
username: xxx
71
+
password: xxxxxxxxx
72
+
insecure: true # Optional, "insecure" field needs to be true if this registry is a http service, default value is false.
73
+
registry.cn-beijing.aliyuncs.com:
74
+
username: xxx # Optional, if the value string is a format of "${env}" or "$env", use the "env" environment variables as username.
75
+
password: xxxxxxxxx # Optional, if the value string is a format of "${env}" or "$env", use the "env" environment variables as password.
76
+
docker.io:
77
+
username: "${env}"
78
+
password: "$env"
79
+
quay.io/coreos:
80
+
username: abc
81
+
password: xxxxxxxxx
82
+
insecure: true
90
83
```
91
84
92
85
#### Image sync configuration file
93
86
94
-
Image sync configuration file defines all the image synchronization rules, the following is an example of `images.json`
95
-
96
-
```java
97
-
{
98
-
// Rules of image synchronization, each rule is a kv pair of source(key) and destination(value).
99
-
100
-
// The source of each rule should not be empty string.
101
-
102
-
// If you need to synchronize images from one source to multi destinations, add more rules.
103
-
104
-
// Both source and destination are docker image url (registry/namespace/repository:tag),
105
-
// with or without tags.
106
-
107
-
// For both source and destination, if destination is not an empty string, "registry/namespace/repository"
108
-
// is needed at least.
109
-
110
-
// You cannot synchronize a whole namespace or a registry but a repository for one rule at most.
111
-
112
-
// The repository name and tag of destination can be deferent from source, which works like
113
-
// "docker pull + docker tag + docker push"
87
+
Image sync configuration file defines all the image synch rules. Each rule is a key/value pair, of which the key refers to "the source images url" and the value refers to "the destination images url". The source/destination images url is mostly the same with the url we use
88
+
in `docker pull/push` commands, but still something different in the "tags and digest" part:
2. If the source images url contains no tags or digest, all the tags of source repository will be synced.
92
+
3. The source images url can have more than one tags, which should be seperated by comma, only the specified tags will be synced.
93
+
4. The source images url can at most one digest, and the destination url should only have no digest or the same digest at the same time.
94
+
5. If the destination url has no digest or tags, it means the source images will keep the same tags or digest after being synced.
95
+
6. The destination url can have more than one tags, the number of which must be the same with the tags in the source images url, then all the source images' tags will be changed to a new one (correspond from left to right).
96
+
7. If the destination url is empty, all the source images will be synced to the "default registry" (by command line parameter) and in the same repository with the source images url.
118
97
119
-
// If a source doesn't include tags, it means all the tags of this repository need to be synchronized,
120
-
// destination should not include tags at this moment.
121
-
122
-
// Each source can include more than one tags, which is split by comma (e.g., "a/b/c:1", "a/b/c:1,2,3").
98
+
You can find the example in [images.yaml](./example/images.yaml) and [images.json](./example/images.json), here we use [images.yaml](./example/images.yaml) for explaination:
123
99
124
-
// If a source includes just one tag (e.g., "a/b/c:1"), it means only one tag need to be synchronized;
125
-
// at this moment, if the destination doesn't include a tag, synchronized image will keep the same tag.
126
-
127
-
// When a source includes more than one tag (e.g., "a/b/c:1,2,3"), at this moment,
128
-
// the destination should not include tags, synchronized images will keep the original tags.
129
-
// e.g., "a/b/c:1,2,3":"x/y/z".
130
-
131
-
// When a destination is an empty string, source will be synchronized to "default-registry/default-namespace"
132
-
// with the same repository name and tags, default-registry and default-namespace can be set by both parameters
0 commit comments