Skip to content

Getting Started

Source code:


Using the ORAS Go client library, you can develop your own push/pull experience:

myclient push ./mything.thang

The package can quickly be imported in other Go-based tools that wish to benefit from the ability to store arbitrary content in container registries.



package main

import (

    ocispec ""


func check(e error) {
    if e != nil {

func main() {
    ref := "localhost:5000/oras:test"
    fileName := "hello.txt"
    fileContent := []byte("Hello World!\n")
    customMediaType := ""

    ctx := context.Background()
    resolver := docker.NewResolver(docker.ResolverOptions{})

    // Push file(s) w custom mediatype to registry
    memoryStore := content.NewMemoryStore()
    desc := memoryStore.Add(fileName, customMediaType, fileContent)
    pushContents := []ocispec.Descriptor{desc}
    fmt.Printf("Pushing %s to %s...\n", fileName, ref)
    desc, err := oras.Push(ctx, resolver, ref, memoryStore, pushContents)
    fmt.Printf("Pushed to %s with digest %s\n", ref, desc.Digest)

    // Pull file(s) from registry and save to disk
    fmt.Printf("Pulling from %s and saving to %s...\n", ref, fileName)
    fileStore := content.NewFileStore("")
    defer fileStore.Close()
    allowedMediaTypes := []string{customMediaType}
    desc, _, err = oras.Pull(ctx, resolver, ref, fileStore, oras.WithAllowedMediaTypes(allowedMediaTypes))
    fmt.Printf("Pulled from %s with digest %s\n", ref, desc.Digest)
    fmt.Printf("Try running 'cat %s'\n", fileName)

Last update: June 29, 2021