0402e0fdbe
Funciones Docker: list/start/stop/remove containers, list/pull/remove images, inspect, logs, run. Tipos: ContainerInfo e ImageInfo. Pre-existentes en el dominio infra, ahora registrados.
1.1 KiB
1.1 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | tested | tests | test_file_path | file_path | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| docker_run_container | function | go | infra | 1.0.0 | impure | func DockerRunContainer(image string, opts DockerRunOpts) (string, error) | Ejecuta un contenedor Docker nuevo a partir de una imagen. Soporta puertos, env vars, volumes, network, detach y auto-remove. Devuelve el ID del contenedor. |
|
false | error_go_core |
|
false | functions/infra/docker_run_container.go |
Ejemplo
id, err := DockerRunContainer("nginx:latest", DockerRunOpts{
Name: "web-server",
Ports: []string{"8080:80"},
Env: map[string]string{"NGINX_HOST": "localhost"},
Detach: true,
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Container ID:", id)
Notas
DockerRunOpts es un struct de opciones definido en el mismo archivo. No se registra como tipo del registry porque es específico de esta función.