-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
How to use libpod as library in my own program? #3445
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
Comments
openshift-ci-robot
added
the
kind/feature
Categorizes issue or PR as related to a new feature.
label
Jun 27, 2019
I think you're missing the storage reexec.Init() call - I'm not at a
computer so I can't get the exact invocation, but you can find it in
cmd/podman/main.go
…On Thu, Jun 27, 2019, 07:31 Thomas Weber ***@***.***> wrote:
/kind feature
*Build a stand alone program with libpod features*
I'd like to work on integrating podman and nomad, see also
hashicorp/nomad#5312 <hashicorp/nomad#5312>
So i started out to build a test program where i want to get familiar with
the libpod api before building the actual nomad plugin.
I did not have any trouble building the tool but i can not manage to get a
libpod.Runtime object.
Also there seems to be no official documentation on using libpod as
library (the project name, however, suggests that it should be possible :-)
)
*Steps to reproduce the issue:*
1. write a cli tool with this source code
package main
import (
"context"
"github.com/containers/libpod/libpod"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetLevel(logrus.TraceLevel)
logrus.Info("Getting Runtime")
ctx := context.TODO()
runtime, err := libpod.NewRuntime(ctx)
if err != nil {
logrus.Fatal("Error creating runtime", err)
return
}
containers, err := runtime.GetContainers()
if err != nil {
logrus.Fatal("Error listing containers", err)
return
}
for _, c := range(containers) {
logrus.Info("Found container", c.Name())
}
runtime.Shutdown(false)
1. Run the program
The program will block forever, it can not initialize the runtime at all
*Debug info*
Logging output
INFO[0000] Getting Runtime
DEBU[0000] Initializing boltdb state at
/var/lib/containers/storage/libpod/bolt_state.db
DEBU[0000] Using graph driver overlay
DEBU[0000] Using graph root /var/lib/containers/storage
DEBU[0000] Using run root /var/run/containers/storage
DEBU[0000] Using static dir /var/lib/containers/storage/libpod
DEBU[0000] Using tmp dir /var/run/libpod
DEBU[0000] Using volume path /var/lib/containers/storage/volumes
DEBU[0000] Set libpod namespace to ""
DEBU[0000] [graphdriver] trying provided driver "overlay"
Process list
153 ? Ss 0:00 /bin/bash
820 ? Sl+ 0:00 _ ./libpod-test
827 ? Sl+ 0:00 _ storage-mountfrom /var/lib/containers/storage
*Questions*
1. do i miss any initialization step? Maybe you can clearify the
start/stop cycle of the library a bit.
2. it would be helpful to build and link the godoc for libpod. Getting
started was rather complex
For sure i miss some important initialization step but i can not find any
clue in the github repo.
Thank you,
Thomas
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3445>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB3AOCHQSWDKXZLHDZPDJH3P4SQJFANCNFSM4H33AMRA>
.
|
@mheon you made my day! Thank you! Cheers, Thomas |
github-actions
bot
added
the
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
label
Sep 24, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
/kind feature
Build a stand alone program with libpod features
I'd like to work on integrating podman and nomad, see also hashicorp/nomad#5312
So i started out to build a test program where i want to get familiar with the libpod api before building the actual nomad plugin.
I did not have any trouble building the tool but i can not manage to get a libpod.Runtime object.
Also there seems to be no official documentation on using libpod as library (the project name, however, suggests that it should be possible :-) )
Steps to reproduce the issue:
The program will block forever, it can not initialize the runtime at all
Debug info
Logging output
Process list
Questions
For sure i miss some important initialization step but i can not find any clue in the github repo.
Thank you,
Thomas
The text was updated successfully, but these errors were encountered: