|
| 1 | +--- |
| 2 | +title: Skopeo |
| 3 | + |
| 4 | +draft: true |
| 5 | + |
| 6 | +author_primary: Jason Andrews |
| 7 | +minutes_to_complete: 10 |
| 8 | +official_docs: https://github.com/containers/skopeo |
| 9 | + |
| 10 | +additional_search_terms: |
| 11 | +- containers |
| 12 | +- images |
| 13 | +- registry |
| 14 | + |
| 15 | +layout: installtoolsall |
| 16 | +multi_install: false |
| 17 | +multitool_install_part: false |
| 18 | +test_images: |
| 19 | +- ubuntu:latest |
| 20 | +test_maintenance: false |
| 21 | +tool_install: true |
| 22 | +weight: 1 |
| 23 | +--- |
| 24 | + |
| 25 | +Skopeo is a command-line utility that performs various operations on container images and image repositories. It does not require a daemon to be running on your computer. |
| 26 | + |
| 27 | +This article explains how to install Skopeo for Ubuntu on Arm. |
| 28 | + |
| 29 | +Skopeo is available for Windows, macOS, and Linux and supports the Arm architecture. Refer to [Installing Skopeo](https://github.com/containers/skopeo/blob/main/install.md) for information about other operating systems and architectures. |
| 30 | + |
| 31 | +## What should I consider before installing Skopeo on Arm? |
| 32 | + |
| 33 | +Confirm you are using an Arm machine by running: |
| 34 | + |
| 35 | +```bash |
| 36 | +uname -m |
| 37 | +``` |
| 38 | + |
| 39 | +The output should be: |
| 40 | +```output |
| 41 | +aarch64 |
| 42 | +``` |
| 43 | + |
| 44 | +If you see a different result, you are not using an Arm computer running 64-bit Linux. |
| 45 | + |
| 46 | +## How do I download and Install Skopeo for Ubuntu on Arm? |
| 47 | + |
| 48 | +The easiest way to install Skopeo is to use the package manager: |
| 49 | + |
| 50 | +```bash |
| 51 | +sudo apt update |
| 52 | +sudo apt install -y skopeo |
| 53 | +``` |
| 54 | + |
| 55 | +Confirm the installation by checking the version: |
| 56 | + |
| 57 | +```bash |
| 58 | +skopeo --version |
| 59 | +``` |
| 60 | + |
| 61 | +To see the help message: |
| 62 | + |
| 63 | +```bash |
| 64 | +skopeo --help |
| 65 | +``` |
| 66 | + |
| 67 | +The output is: |
| 68 | + |
| 69 | +```output |
| 70 | +Various operations with container images and container image registries |
| 71 | +
|
| 72 | +Usage: |
| 73 | + skopeo [flags] |
| 74 | + skopeo [command] |
| 75 | +
|
| 76 | +Available Commands: |
| 77 | + copy Copy an IMAGE-NAME from one location to another |
| 78 | + delete Delete image IMAGE-NAME |
| 79 | + generate-sigstore-key Generate a sigstore public/private key pair |
| 80 | + help Help about any command |
| 81 | + inspect Inspect image IMAGE-NAME |
| 82 | + list-tags List tags in the transport/repository specified by the SOURCE-IMAGE |
| 83 | + login Login to a container registry |
| 84 | + logout Logout of a container registry |
| 85 | + manifest-digest Compute a manifest digest of a file |
| 86 | + standalone-sign Create a signature using local files |
| 87 | + standalone-verify Verify a signature using local files |
| 88 | + sync Synchronize one or more images from one location to another |
| 89 | +
|
| 90 | +Flags: |
| 91 | + --command-timeout duration timeout for the command execution |
| 92 | + --debug enable debug output |
| 93 | + -h, --help help for skopeo |
| 94 | + --insecure-policy run the tool without any policy check |
| 95 | + --override-arch ARCH use ARCH instead of the architecture of the machine for choosing images |
| 96 | + --override-os OS use OS instead of the running OS for choosing images |
| 97 | + --override-variant VARIANT use VARIANT instead of the running architecture variant for choosing images |
| 98 | + --policy string Path to a trust policy file |
| 99 | + --registries.d DIR use registry configuration files in DIR (e.g. for container signature storage) |
| 100 | + --tmpdir string directory used to store temporary files |
| 101 | + -v, --version Version for Skopeo |
| 102 | +
|
| 103 | +Use "skopeo [command] --help" for more information about a command. |
| 104 | +``` |
| 105 | + |
| 106 | +## How do I get started with Skopeo? |
| 107 | + |
| 108 | +Some commands to get you started with Skopeo are demonstrated below. |
| 109 | + |
| 110 | +### How can I check if a container image supports Arm? |
| 111 | + |
| 112 | +To find out if an image is multi-architecture, including Arm, you can inspect the image's manifest. |
| 113 | + |
| 114 | +For example, to check if the dev container available for creating Arm Learning Paths supports the Arm architecture run: |
| 115 | + |
| 116 | +```bash |
| 117 | +skopeo inspect --raw docker://docker.io/armswdev/learn-dev-container:latest | jq '.manifests[] | select(.platform.architecture == "arm64")' |
| 118 | +``` |
| 119 | + |
| 120 | +The output is similar to: |
| 121 | + |
| 122 | +```output |
| 123 | +{ |
| 124 | + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", |
| 125 | + "size": 1574, |
| 126 | + "digest": "sha256:b7abfdc06d4cb06dfbb644f0d7c50202f99f83298da7903ea6463de23b55fb10", |
| 127 | + "platform": { |
| 128 | + "architecture": "arm64", |
| 129 | + "os": "linux" |
| 130 | + } |
| 131 | +} |
| 132 | +``` |
| 133 | + |
| 134 | +If the command returns a result for an image, the image supports the `arm64` architecture. |
| 135 | + |
| 136 | +### How can I check if a container image supports multiple architectures? |
| 137 | + |
| 138 | +To find out if an image supports both `arm64` and `amd64` architectures, you can inspect the image's manifest for both architectures. |
| 139 | + |
| 140 | +For example, to check if the same dev container supports both architectures run: |
| 141 | + |
| 142 | +```bash |
| 143 | +skopeo inspect --raw docker://docker.io/armswdev/learn-dev-container:latest | jq '.manifests[] | select(.platform.architecture == "arm64" or .platform.architecture == "amd64")' |
| 144 | +``` |
| 145 | + |
| 146 | +The output confirms that both `arm64` and `amd64` are supported architectures as shown below: |
| 147 | + |
| 148 | +```output |
| 149 | +{ |
| 150 | + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", |
| 151 | + "size": 1574, |
| 152 | + "digest": "sha256:15fe2dc0925c6e5da27048edcd034660f51216ad700cb7cf12cb7779c16e9bce", |
| 153 | + "platform": { |
| 154 | + "architecture": "amd64", |
| 155 | + "os": "linux" |
| 156 | + } |
| 157 | +} |
| 158 | +{ |
| 159 | + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", |
| 160 | + "size": 1574, |
| 161 | + "digest": "sha256:b7abfdc06d4cb06dfbb644f0d7c50202f99f83298da7903ea6463de23b55fb10", |
| 162 | + "platform": { |
| 163 | + "architecture": "arm64", |
| 164 | + "os": "linux" |
| 165 | + } |
| 166 | +} |
| 167 | +``` |
| 168 | + |
| 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 | + |
| 284 | +## What are some other uses for Skopeo? |
| 285 | + |
| 286 | +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. |
| 287 | + |
| 288 | +```bash |
| 289 | +skopeo copy docker://docker.io/armswdev/uname:latest dir:./uname |
| 290 | +``` |
| 291 | + |
| 292 | +The output is: |
| 293 | + |
| 294 | +```output |
| 295 | +Getting image source signatures |
| 296 | +Copying blob cd741b12a7ea done | |
| 297 | +Copying config d11135df72 done | |
| 298 | +Writing manifest to image destination |
| 299 | +``` |
| 300 | + |
| 301 | +Inspect an image in a remote registry: |
| 302 | + |
| 303 | +```bash |
| 304 | +skopeo inspect docker://docker.io/armswdev/uname:latest |
| 305 | +``` |
| 306 | + |
| 307 | +The output is: |
| 308 | + |
| 309 | +```output |
| 310 | +{ |
| 311 | + "Name": "docker.io/armswdev/uname", |
| 312 | + "Digest": "sha256:4f1fe1e1e1ad179bb2cec6b3c8b458d6ead02bd7459798a357791353b867462d", |
| 313 | + "RepoTags": [ |
| 314 | + "latest" |
| 315 | + ], |
| 316 | + "Created": "2023-03-08T04:32:41.063980445Z", |
| 317 | + "DockerVersion": "", |
| 318 | + "Labels": { |
| 319 | + "org.opencontainers.image.ref.name": "ubuntu", |
| 320 | + "org.opencontainers.image.version": "22.04" |
| 321 | + }, |
| 322 | + "Architecture": "arm64", |
| 323 | + "Os": "linux", |
| 324 | + "Layers": [ |
| 325 | + "sha256:cd741b12a7eaa64357041c2d3f4590c898313a7f8f65cd1577594e6ee03a8c38" |
| 326 | + ], |
| 327 | + "LayersData": [ |
| 328 | + { |
| 329 | + "MIMEType": "application/vnd.oci.image.layer.v1.tar+gzip", |
| 330 | + "Digest": "sha256:cd741b12a7eaa64357041c2d3f4590c898313a7f8f65cd1577594e6ee03a8c38", |
| 331 | + "Size": 27347481, |
| 332 | + "Annotations": null |
| 333 | + } |
| 334 | + ], |
| 335 | + "Env": [ |
| 336 | + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 337 | + ] |
| 338 | +} |
| 339 | +``` |
| 340 | + |
| 341 | +List tags in a remote registry for the Ubuntu image with many tags: |
| 342 | + |
| 343 | +```bash |
| 344 | +skopeo list-tags docker://docker.io/library/ubuntu |
| 345 | +``` |
| 346 | + |
| 347 | +The partial output is: |
| 348 | + |
| 349 | +```output |
| 350 | +{ |
| 351 | + "Repository": "docker.io/library/ubuntu", |
| 352 | + "Tags": [ |
| 353 | + "10.04", |
| 354 | + "12.04", |
| 355 | + "12.04.5", |
| 356 | + "12.10", |
| 357 | + "13.04", |
| 358 | + "13.10", |
| 359 | + "14.04", |
| 360 | + "14.04.1", |
| 361 | + "14.04.2", |
| 362 | + "14.04.3", |
| 363 | + "14.04.4", |
| 364 | + "14.04.5", |
| 365 | + "14.10", |
| 366 | + "15.04", |
| 367 | + "15.10", |
| 368 | + "16.04", |
| 369 | + "16.10", |
| 370 | + "17.04", |
| 371 | + "17.10", |
| 372 | + "18.04", |
| 373 | + "18.10", |
| 374 | + "19.04", |
| 375 | + "19.10", |
| 376 | + "20.04", |
| 377 | + "20.10", |
| 378 | + "21.04", |
| 379 | + "21.10", |
| 380 | + "22.04", |
| 381 | + "22.10", |
| 382 | + "23.04", |
| 383 | + "23.10", |
| 384 | + "24.04", |
| 385 | + "24.10", |
| 386 | + "25.04", |
| 387 | +< many more tag with Ubuntu release names omitted> |
| 388 | +``` |
| 389 | + |
| 390 | +You are ready to use Skopeo for your projects. |
0 commit comments