import "github.com/docker/docker/engine" // create a new Docker engine client client, err := engine.New("unix:///var/run/docker.sock") // get the value of the DOCKER_HOST environment variable dockerHost, found := client.Env().Get("DOCKER_HOST") if found { fmt.Printf("DOCKER_HOST is set to %s\n", dockerHost) }
import "github.com/docker/docker/engine" // create a new Docker engine client client, err := engine.New("unix:///var/run/docker.sock") // set the value of the MY_VAR environment variable to "hello world" client.Env().Set("MY_VAR", "hello world")
import "github.com/docker/docker/engine" // create a new Docker engine client client, err := engine.New("unix:///var/run/docker.sock") // delete the value of the MY_VAR environment variable client.Env().Delete("MY_VAR")In all of the above examples, we are using the "engine" package from the github.com/docker/docker repository to interact with the Docker environment variables. The package provides a simple and consistent interface for managing environment variables in a Docker container.