Skip to content

Commit ced163f

Browse files
Merge pull request #1450 from jasonrandrews/review
Update Skopeo install guide
2 parents 292bdae + 955080d commit ced163f

File tree

1 file changed

+0
-117
lines changed

1 file changed

+0
-117
lines changed

content/install-guides/skopeo.md

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: Skopeo
33

4-
draft: true
5-
64
author_primary: Jason Andrews
75
minutes_to_complete: 10
86
official_docs: https://github.com/containers/skopeo
@@ -166,121 +164,6 @@ The output confirms that both `arm64` and `amd64` are supported architectures as
166164
}
167165
```
168166

169-
### Can I use a script to check if a container image supports the Arm architecture?
170-
171-
You can run a script to check container images for `arm64` support.
172-
173-
The script performs the following tasks:
174-
- Get a token for the repository
175-
- Read the image manifest
176-
- Check the manifest for architecture support
177-
178-
Make sure Python3 is installed on your computer.
179-
180-
Use a text editor to copy the Python code below to a file named `check-image.py`.
181-
182-
```python
183-
import requests
184-
import sys
185-
import os
186-
import argparse
187-
from typing import List, Dict, Tuple
188-
189-
# Target architectures to check
190-
TARGET_ARCHITECTURES = {'amd64', 'arm64'}
191-
TIMEOUT_SECONDS = 10
192-
193-
def get_auth_token(repository: str) -> str:
194-
"""Get Docker Hub authentication token."""
195-
url = "https://auth.docker.io/token"
196-
params = {
197-
"service": "registry.docker.io",
198-
"scope": f"repository:{repository}:pull"
199-
}
200-
try:
201-
response = requests.get(url, params=params, timeout=TIMEOUT_SECONDS)
202-
response.raise_for_status()
203-
return response.json()['token']
204-
except requests.exceptions.RequestException as e:
205-
print(f"Failed to get auth token: {e}", file=sys.stderr)
206-
sys.exit(1)
207-
208-
def get_manifest(repository: str, tag: str, token: str) -> Dict:
209-
"""Fetch manifest for specified image."""
210-
headers = {
211-
'Accept': 'application/vnd.docker.distribution.manifest.list.v2+json',
212-
'Authorization': f'Bearer {token}'
213-
}
214-
url = f"https://registry-1.docker.io/v2/{repository}/manifests/{tag}"
215-
try:
216-
response = requests.get(url, headers=headers, timeout=TIMEOUT_SECONDS)
217-
response.raise_for_status()
218-
return response.json()
219-
except requests.exceptions.RequestException as e:
220-
print(f"Failed to get manifest: {e}", file=sys.stderr)
221-
sys.exit(1)
222-
223-
def check_architectures(manifest: Dict) -> List[str]:
224-
"""Check available architectures in the manifest."""
225-
if manifest.get('manifests'):
226-
archs = [m['platform']['architecture'] for m in manifest['manifests']]
227-
return archs
228-
else:
229-
return []
230-
231-
def parse_image_spec(image: str) -> Tuple[str, str]:
232-
"""Parse image specification into repository and tag."""
233-
if ':' in image:
234-
repository, tag = image.split(':', 1)
235-
else:
236-
repository, tag = image, 'latest'
237-
238-
if '/' not in repository:
239-
repository = f'library/{repository}'
240-
return repository.lower(), tag
241-
242-
def parse_args():
243-
"""Parse command line arguments."""
244-
parser = argparse.ArgumentParser(description='Check Docker image architectures')
245-
parser.add_argument('image', help='Docker image name (format: name:tag)')
246-
return parser.parse_args()
247-
248-
if __name__ == "__main__":
249-
args = parse_args()
250-
repository, tag = parse_image_spec(args.image)
251-
252-
token = get_auth_token(repository)
253-
manifest = get_manifest(repository, tag, token)
254-
architectures = check_architectures(manifest)
255-
256-
if not architectures:
257-
print(f"No architectures found for {args.image}", file=sys.stderr)
258-
sys.exit(1)
259-
260-
available_targets = TARGET_ARCHITECTURES.intersection(architectures)
261-
missing_targets = TARGET_ARCHITECTURES - set(architectures)
262-
263-
if not missing_targets:
264-
print(f"✓ Image {args.image} supports all required architectures")
265-
else:
266-
print(f"✗ Image {args.image} is missing architectures: {', '.join(missing_targets)}")
267-
print(f"Available architectures: {', '.join(architectures)}")
268-
```
269-
270-
The script queries Docker Hub. If needed, you can change the registry and the architecture list to meet your needs.
271-
272-
Run the script asking about Alpine Linux:
273-
274-
```bash
275-
python3 ./check-image.py alpine:3.21.0
276-
```
277-
278-
The output indicates that the image supports both `arm64` and `amd64`:
279-
280-
```output
281-
✓ Image alpine:3.21.0 supports all required architectures
282-
```
283-
284167
## What are some other uses for Skopeo?
285168

286169
Copy an image from a registry to a local directory. This command is similar to `docker pull` and will copy the image from the remote registry to your local directory.

0 commit comments

Comments
 (0)