gocker

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 3 Imported by: 0

README

Gocker

Descrizione dell'immagine

Gocker is a CLI generator to create and execute Docker commands in Go.

Installation

To install Gocker, use go get:

go get github.com/rojack96/gocker
Basic Example

Here is an example of how to use Gocker to execute a Docker Compose command:

package main

import (
    "fmt"
    "github.com/rojack96/gocker"
)

func main() {
    compose := gocker.Compose()

    result := compose.FileName("compose.yml").Up().Build().ServiceNames("hello-world")

    fmt.Println(result.GetCommand())
    // output: "docker compose --file compose.yml up --build hello-world"

    result.Exec(false)
}
Supported Commands

Gocker supports Docker commands for version 26.1.3.

Currently, all compose commands are implemented, and support for other Docker commands is coming soon.

Create a command
// Create compose instance
compose := gocker.Compose()

result := compose.FileName("compose.yml"). //(optional) Docker file
                    Up(). // up command
                    Build(). // --build command
                    ServiceNames("hello-world") // service name to start, if empty, all services will be started

fmt.Println(result.GetCommand())
// output: "docker compose --file compose.yml up --build hello-world"
Execute a command
// Create compose instance
compose := gocker.Compose()

result := compose.FileName("compose.yml"). // Docker file, if empty it will not be included
                    Up(). // up command
                    Build(). // --build command
                    ServiceNames("hello-world") // service name to start, if empty, all services will be started
result.Exec(false) // if true, the command will be executed with administrator privileges

Contributing

If you want to contribute to Gocker, feel free to do so! You can create a pull request or open an issue to discuss changes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

func Compose() *compose.Compose

Compose - Define and run multi-container applications with Docker.

func Run

func Run() *run.Run

Run - Create and run a new container from an image.

func System added in v0.2.0

func System() *system.System

System - Manage Docker.

Types

This section is empty.

Directories

Path Synopsis
commands
run

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL