Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple documentation how to use c/image with podman's rootless mode #1405

Merged
merged 1 commit into from Nov 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 58 additions & 19 deletions doc.go
@@ -1,32 +1,71 @@
// Package image provides libraries and commands to interact with containers images.
// The package image provides libraries and commands to interact with container images.
//
// package main
//
// import (
// "context"
// "fmt"
// "context"
// "fmt"
//
// "github.com/containers/image/v5/docker"
// "github.com/containers/image/v5/docker"
// )
//
// func main() {
// ref, err := docker.ParseReference("//fedora")
// if err != nil {
// panic(err)
// }
// ctx := context.Background()
// img, err := ref.NewImage(ctx, nil)
// if err != nil {
// panic(err)
// }
// defer img.Close()
// b, _, err := img.Manifest(ctx)
// if err != nil {
// panic(err)
// }
// fmt.Printf("%s", string(b))
// ref, err := docker.ParseReference("//fedora")
// if err != nil {
// panic(err)
// }
// ctx := context.Background()
// img, err := ref.NewImage(ctx, nil)
// if err != nil {
// panic(err)
// }
// defer img.Close()
// b, _, err := img.Manifest(ctx)
// if err != nil {
// panic(err)
// }
// fmt.Printf("%s", string(b))
// }
//
//
// ## Notes on running in rootless mode
//
// If your application needs to access a containers/storage store in rootless
// mode, then the following additional steps have to be performed at start-up of
// your application:
//
// package main
//
// import (
// "github.com/containers/storage/pkg/reexec"
// "github.com/syndtr/gocapability/capability"
// "github.com/containers/storage/pkg/unshare"
// )
//
// var neededCapabilities = []capability.Cap{
// capability.CAP_CHOWN,
// capability.CAP_DAC_OVERRIDE,
// capability.CAP_FOWNER,
// capability.CAP_FSETID,
// capability.CAP_MKNOD,
// capability.CAP_SETFCAP,
// }
//
// func main() {
// reexec.Init()
//
// capabilities, err := capability.NewPid(0)
// if err != nil {
// panic(err)
// }
// for _, cap := range neededCapabilities {
// if !capabilities.Get(capability.EFFECTIVE, cap) {
// // We miss a capability we need, create a user namespaces
// unshare.MaybeReexecUsingUserNamespace(true)
dcermak marked this conversation as resolved.
Show resolved Hide resolved
// }
// }
// // rest of your code follows here
// }
//
// TODO(runcom)
package image