Golang to use Podman REST API
Hi all I am looking for some code examples in Golang to use Podman REST API. Is there a repository or some code examples that i can refer to? Also while looking at the Podman REST API. (https://docs.podman.io/en/latest/_static/api.html). how do i call the "podman run" using the REST API ? Regards Niranjan.
Hi Niranjan, Thanks for reaching out. On Mon, Nov 22, 2021 at 8:11 AM <niranjan@ashoo.in> wrote:
Hi all
I am looking for some code examples in Golang to use Podman REST API. Is there a repository or some code examples that i can refer to?
Also while looking at the Podman REST API. ( https://docs.podman.io/en/latest/_static/api.html). how do i call the "podman run" using the REST API ?
A container run boils down to create+start. Some examples can be found in how the remote client of Podman is using the Go-bindings for the REST API, for example: https://github.com/containers/podman/blob/main/pkg/domain/infra/tunnel/conta... The bindings live in pkg/bindings/{containers,images,...}. Kind regards, Valentin
Regards Niranjan. _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
Also -> https://github.com/containers/podman/tree/main/pkg/bindings On Mon, Nov 22, 2021 at 3:12 AM Valentin Rothberg <rothberg@redhat.com> wrote:
Hi Niranjan,
Thanks for reaching out.
On Mon, Nov 22, 2021 at 8:11 AM <niranjan@ashoo.in> wrote:
Hi all
I am looking for some code examples in Golang to use Podman REST API. Is there a repository or some code examples that i can refer to?
Also while looking at the Podman REST API. ( https://docs.podman.io/en/latest/_static/api.html). how do i call the "podman run" using the REST API ?
A container run boils down to create+start. Some examples can be found in how the remote client of Podman is using the Go-bindings for the REST API, for example: https://github.com/containers/podman/blob/main/pkg/domain/infra/tunnel/conta...
The bindings live in pkg/bindings/{containers,images,...}.
Kind regards, Valentin
Regards Niranjan. _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
_______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
On Mon, Nov 22, 2021, at 8:30 PM, Brent Baude wrote:
Also -> https://github.com/containers/podman/tree/main/pkg/bindings
When using the above bindings, I am getting below error: <snip> # pkg-config --cflags -- devmapper Package devmapper was not found in the pkg-config search path. Perhaps you should add the directory containing `devmapper.pc' to the PKG_CONFIG_PATH environment variable Package 'devmapper', required by 'virtual:world', not found pkg-config: exit status 1 # github.com/containers/storage/drivers/btrfs ../../../go/pkg/mod/github.com/containers/storage@v1.36.0/drivers/btrfs/btrfs.go:8:10: fatal error: btrfs/ioctl.h: No such file or directory #include <btrfs/ioctl.h> ^~~~~~~~~~~~~~~ compilation terminated. </snip> Versions: Go: go version go1.15.14 linux/amd64 OS: Red Hat Enterprise Linux release 8.4 (Ootpa) (CSB) Go.mod: module example.com go 1.15 require ( github.com/containers/podman/v2 v2.2.1 // indirect github.com/containers/podman/v3 v3.4.2 ) Code: <snip a2.go> package main import ( "context" "fmt" "os" "github.com/containers/podman/v3/pkg/bindings" "github.com/containers/podman/v3/pkg/bindings/images" ) const ( socketPath = "unix://run/user/11567/podman/podman.sock" imageName = "registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.9" ) func main() { conn, err := bindings.NewConnection(context.Background(), socketPath) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Printf("conn is of type: %T\n", conn) _, err = images.Pull(conn, imageName, nil) if err != nil { fmt.Println(err) os.Exit(1) } } </snip> When i execute the above code , i get the error described above.
On Mon, Nov 22, 2021 at 3:12 AM Valentin Rothberg <rothberg@redhat.com> wrote:
Hi Niranjan,
Thanks for reaching out.
On Mon, Nov 22, 2021 at 8:11 AM <niranjan@ashoo.in> wrote:
Hi all
I am looking for some code examples in Golang to use Podman REST API. Is there a repository or some code examples that i can refer to?
Also while looking at the Podman REST API. (https://docs.podman.io/en/latest/_static/api.html). how do i call the "podman run" using the REST API ?
A container run boils down to create+start. Some examples can be found in how the remote client of Podman is using the Go-bindings for the REST API, for example: https://github.com/containers/podman/blob/main/pkg/domain/infra/tunnel/conta...
The bindings live in pkg/bindings/{containers,images,...}. Kind regards, Valentin
Regards Niranjan. _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
On Tue, Nov 30, 2021 at 5:57 AM <niranjan@ashoo.in> wrote:
On Mon, Nov 22, 2021, at 8:30 PM, Brent Baude wrote:
Also -> https://github.com/containers/podman/tree/main/pkg/bindings
When using the above bindings, I am getting below error:
<snip> # pkg-config --cflags -- devmapper Package devmapper was not found in the pkg-config search path. Perhaps you should add the directory containing `devmapper.pc' to the PKG_CONFIG_PATH environment variable Package 'devmapper', required by 'virtual:world', not found pkg-config: exit status 1 # github.com/containers/storage/drivers/btrfs ../../../go/pkg/mod/ github.com/containers/storage@v1.36.0/drivers/btrfs/btrfs.go:8:10: fatal error: btrfs/ioctl.h: No such file or directory #include <btrfs/ioctl.h> ^~~~~~~~~~~~~~~ compilation terminated. </snip>
Add the following tags to your `go build`: -tags "exclude_graphdriver_devicemapper exclude_graphdriver_btrfs" That will exclude the two graph drivers from the build. Ideally the drivers should not be needed at all but I assume that *some* transitive dependency of the bindings are pulling them into the build. Kind regards, Valentin
Versions: Go: go version go1.15.14 linux/amd64 OS: Red Hat Enterprise Linux release 8.4 (Ootpa) (CSB)
Go.mod:
module example.com
go 1.15
require ( github.com/containers/podman/v2 v2.2.1 // indirect github.com/containers/podman/v3 v3.4.2 ) Code:
<snip a2.go> package main
import ( "context" "fmt" "os" "github.com/containers/podman/v3/pkg/bindings" "github.com/containers/podman/v3/pkg/bindings/images" )
const ( socketPath = "unix://run/user/11567/podman/podman.sock" imageName = " registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.9" ) func main() { conn, err := bindings.NewConnection(context.Background(), socketPath) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Printf("conn is of type: %T\n", conn) _, err = images.Pull(conn, imageName, nil) if err != nil { fmt.Println(err) os.Exit(1) } } </snip> When i execute the above code , i get the error described above.
On Mon, Nov 22, 2021 at 3:12 AM Valentin Rothberg <rothberg@redhat.com> wrote:
Hi Niranjan,
Thanks for reaching out.
On Mon, Nov 22, 2021 at 8:11 AM <niranjan@ashoo.in> wrote:
Hi all
I am looking for some code examples in Golang to use Podman REST API. Is there a repository or some code examples that i can refer to?
Also while looking at the Podman REST API. ( https://docs.podman.io/en/latest/_static/api.html). how do i call the "podman run" using the REST API ?
A container run boils down to create+start. Some examples can be found in how the remote client of Podman is using the Go-bindings for the REST API, for example: https://github.com/containers/podman/blob/main/pkg/domain/infra/tunnel/conta...
The bindings live in pkg/bindings/{containers,images,...}. Kind regards, Valentin
Regards Niranjan. _______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
_______________________________________________ Podman mailing list -- podman@lists.podman.io To unsubscribe send an email to podman-leave@lists.podman.io
participants (3)
-
Brent Baude -
niranjan@ashoo.in -
Valentin Rothberg