{"id":42666382,"url":"https://github.com/helmutkemper/iotmaker.docker","last_synced_at":"2026-01-29T10:08:38.102Z","repository":{"id":53540387,"uuid":"196730685","full_name":"helmutkemper/iotmaker.docker","owner":"helmutkemper","description":"Containers manager by golang code / Gerenciador de contêineres por código golang","archived":false,"fork":false,"pushed_at":"2023-05-11T20:44:38.000Z","size":4600,"stargazers_count":2,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T16:47:30.013Z","etag":null,"topics":["containers","docker","golang","moby"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helmutkemper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-13T14:27:11.000Z","updated_at":"2022-11-16T16:30:27.000Z","dependencies_parsed_at":"2024-06-19T16:23:43.138Z","dependency_job_id":"6ac69cf7-b76c-4bca-9bd0-1fad44b497b8","html_url":"https://github.com/helmutkemper/iotmaker.docker","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/helmutkemper/iotmaker.docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmutkemper%2Fiotmaker.docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmutkemper%2Fiotmaker.docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmutkemper%2Fiotmaker.docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmutkemper%2Fiotmaker.docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helmutkemper","download_url":"https://codeload.github.com/helmutkemper/iotmaker.docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmutkemper%2Fiotmaker.docker/sbom","scorecard":{"id":460605,"data":{"date":"2025-08-11","repo":{"name":"github.com/helmutkemper/iotmaker.docker","commit":"05ce30d2fcbc323c9834ead44649363ebd5ff2b1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: Dockerfile_EXAMPLE:6","Warn: containerImage not pinned by hash: v1.0.1/test/small_test_server_port_3000/dockerfile:1","Warn: containerImage not pinned by hash: v1.0.1/test/small_test_server_port_3000_exit_after_15s/dockerfile:1","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:28","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:29","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:30","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:31","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:32","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:33","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:34","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:35","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:36","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:37","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:38","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:39","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:40","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:41","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:42","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:43","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:44","Warn: goCommand not pinned by hash: Dockerfile_EXAMPLE:45","Info:   0 out of   3 containerImage dependencies pinned","Info:   0 out of  18 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":2,"reason":"badge detected: InProgress","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"22 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-hqxw-f8mx-cpmw","Warn: Project is vulnerable to: GO-2022-0985 / GHSA-rc4r-wh2q-q6c4","Warn: Project is vulnerable to: GO-2022-1107 / GHSA-vp35-85q5-9f25","Warn: Project is vulnerable to: GO-2023-1699 / GHSA-232p-vwff-86mp","Warn: Project is vulnerable to: GO-2023-1700 / GHSA-33pg-m6jh-5237","Warn: Project is vulnerable to: GO-2023-1701 / GHSA-6wrf-mxfj-pf5p","Warn: Project is vulnerable to: GHSA-jq35-85cj-fj4p","Warn: Project is vulnerable to: GHSA-mq39-4gv4-mvpx","Warn: Project is vulnerable to: GO-2024-3005 / GHSA-v23v-6jw2-98fq","Warn: Project is vulnerable to: GO-2024-2512 / GHSA-xw73-rw38-6vjc","Warn: Project is vulnerable to: GO-2025-3829 / GHSA-4vq8-7jfc-9cvp","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T11:02:38.463Z","repository_id":53540387,"created_at":"2025-08-19T11:02:38.463Z","updated_at":"2025-08-19T11:02:38.463Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28875450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T09:47:23.353Z","status":"ssl_error","status_checked_at":"2026-01-29T09:47:19.357Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","docker","golang","moby"],"created_at":"2026-01-29T10:08:37.313Z","updated_at":"2026-01-29T10:08:38.091Z","avatar_url":"https://github.com/helmutkemper.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iotmaker.docker\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/helmutkemper/iotmaker.docker/blob/master/image/Go-Logo_LightBlue.svg\" width=\"500\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/helmutkemper/iotmaker.docker\"\u003e\n    \u003cimg src=\"https://goreportcard.com/badge/github.com/helmutkemper/iotmaker.docker\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/helmutkemper/iotmaker.docker/v1.0.1?tab=doc\"\u003e\n    \u003cimg src=\"https://github.com/helmutkemper/iotmaker.docker/blob/master/image/godoc.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Português: \n\u003e \n\u003e Por favor, não use este projeto diretamente. Caso você necessite gerar containers docker, controlados por \n\u003e código golang e gerar senários de caos, use o projeto [Docker Builder](https://github.com/helmutkemper/iotmaker.docker.builder).\n\n\u003e English:\n\u003e \n\u003e Please do not use this project directly. If you need to generate docker containers, controlled by golang \n\u003e code and generate chaos scenarios, use the [Docker Builder](https://github.com/helmutkemper/iotmaker.docker.builder)\n\u003e project.\n\n\u003e Português:\n\u003e \n\u003e Nota: todos os testes estão processando com sucesso, porém, os testes geram containers e ferramentas on-line de testes \n\u003e não deixam containers gerarem containers, por isto, rode os testes na mão em máquina local (um a um, não rode todos ao \n\u003e mesmo tempo), caso queira.\n\n\u003e Emglish:\n\u003e \n\u003e Note: all tests are processing successfully, however, the tests generate containers and online testing tools do not \n\u003e let containers generate containers, so run the tests by hand on a local machine (one by one, do not run them all at \n\u003e the same time), if you want.\n\n### Português\n\nEste projeto é uma forma simples de gerenciar containers por código **Golang**.\n\nPara saber como usar, basta seguir os códigos de testes na forma de exemplos. Todos eles\nsão funcionais.\n\nO código tem em torno de 90% de cobertura com testes e documentação em português e \ninglês.\n\n### English\n\nThis project is a simple way to manage containers by code **Golang**.\n\nTo learn how to use, just follow the test codes as examples. All examples are functional.\n\nThe code has around 90% coverage with tests and documentation in Portuguese and English.\n\n### Exemplos / Samples\n\n**Português:** Monta um servidor baseado em um diretório local:\n\n**English:** Build a small server based on a local directory:\n```golang\npackage main\n\nimport (\n  \"bytes\"\n  \"errors\"\n  \"fmt\"\n  \"github.com/docker/docker/api/types/mount\"\n  \"github.com/docker/docker/api/types/network\"\n  \"github.com/docker/go-connections/nat\"\n  \"github.com/helmutkemper/iotmaker.docker/util\"\n  iotmakerDocker \"github.com/helmutkemper/iotmaker.docker/v1.0.0.0-RC\"\n  \"io/ioutil\"\n  \"net/http\"\n  \"os\"\n  \"path/filepath\"\n)\n\nfunc main() {\n    var err error\n    var containerId string\n    var imageId string\n    var networkId string\n    var dockerSys *iotmakerDocker.DockerSystem\n\n    var networkAutoConfiguration *iotmakerDocker.NextNetworkAutoConfiguration\n    var networkNextAddress *network.NetworkingConfig\n\n    // English: make a channel to end goroutine\n    // Português: monta um canal para terminar a goroutine\n    var chProcessEnd = make(chan bool, 1)\n\n    // English: make a channel [optional] to print build output\n    // Português: monta o canal [opcional] para imprimir a saída do build\n    var chStatus = make(chan iotmakerDocker.ContainerPullStatusSendToChannel, 1)\n\n    // English: make a thread to monitoring and print channel data\n    // Português: monta uma thread para imprimir os dados do canal\n    go func(chStatus chan iotmakerDocker.ContainerPullStatusSendToChannel, chProcessEnd chan bool) {\n\n      for {\n        select {\n        case \u003c-chProcessEnd:\n          return\n\n        case status := \u003c-chStatus:\n          // English: remove this comment to see all build status\n          // Português: remova este comentário para vê todo o status da criação da imagem\n          fmt.Printf(\"image pull status: %+v\\n\", status)\n\n          if status.Closed == true {\n            fmt.Println(\"image pull complete!\")\n\n            // English: Eliminate this goroutine after process end\n            // Português: Elimina a goroutine após o fim do processo\n            return\n          }\n        }\n      }\n\n    }(chStatus, chProcessEnd)\n\n    // English: searches for the folder containing the test server\n    // Português: procura pela pasta contendo o servidor de teste\n    var smallServerPath string\n    smallServerPath, err = util.FileFindRecursively(\"small_server_p3000\")\n    if err != nil {\n      panic(err)\n    }\n\n    // English: turns the path into an absolute path\n    // Português: transforma o caminho em caminho absoluto\n    smallServerPath, err = filepath.Abs(smallServerPath)\n    if err != nil {\n      panic(err)\n    }\n\n    // English: 'static' folder path\n    // Português: caminho da pasta 'static'\n    var smallServerPathStatic string\n    smallServerPathStatic = smallServerPath + string(os.PathSeparator) + \"static\"\n\n    // English: 'index.html' file path\n    // Português: caminho do arquivo 'index.html'\n    var smallServerPathStaticContent string\n    smallServerPathStaticContent = smallServerPathStatic + string(os.PathSeparator) + \"index.html\"\n\n    // English: create a new default client. Please, use: err, dockerSys = factoryDocker.NewClient()\n    // Português: cria um novo cliente com configurações padrão. Por favor, usr: err, dockerSys = factoryDocker.NewClient()\n    dockerSys = \u0026iotmakerDocker.DockerSystem{}\n    dockerSys.ContextCreate()\n    err = dockerSys.ClientCreate()\n    if err != nil {\n      panic(err)\n    }\n\n    // English: garbage collector and deletes networks and images whose name contains the term 'delete'\n    // Português: coletor de lixo e apaga redes e imagens cujo o nome contém o temo 'delete'\n    err = dockerSys.RemoveAllByNameContains(\"delete\")\n    if err != nil {\n      panic(err)\n    }\n\n    // English: create a network named 'network_delete_before_test'\n    // Português: cria uma nova rede de nome 'network_delete_before_test'\n    networkId, networkAutoConfiguration, err = dockerSys.NetworkCreate(\n      \"network_delete_before_test\",\n      iotmakerDocker.KNetworkDriveBridge,\n      \"local\",\n      \"10.0.0.0/16\",\n      \"10.0.0.1\",\n    )\n    if err != nil {\n      panic(err)\n    }\n\n    if networkId == \"\" {\n      err = errors.New(\"network id was not generated\")\n      panic(err)\n    }\n\n    // English: get next ip address from network, '10.0.0.2'\n    // Português: pega o próxima endereço da rede, '10.0.0.2'\n    err, networkNextAddress = networkAutoConfiguration.GetNext()\n    if err != nil {\n      panic(err)\n    }\n\n    // English: build a new image from folder 'small_test_server_port_3000'\n    // Português: monta uma imagem a partir da pasta 'small_test_server_port_3000'\n    imageId, err = dockerSys.ImageBuildFromFolder(\n      smallServerPath,\n      []string{\n        \"image_server_delete_before_test:latest\", // image name\n      },\n      \u0026chStatus, // [channel|nil]\n    )\n    if err != nil {\n      panic(err)\n    }\n\n    if imageId == \"\" {\n      err = errors.New(\"image ID was not generated\")\n      panic(err)\n    }\n\n    // English: building a multi-step image leaves large and useless images, taking up space on the HD.\n    // Português: construir uma imagem de múltiplas etapas deixa imagens grandes e sem serventia, ocupando espaço no HD.\n    err = dockerSys.ImageGarbageCollector()\n    if err != nil {\n      panic(err)\n    }\n\n    // English: mount and start a container\n    // Português: monta i inicializa o container\n    containerId, err = dockerSys.ContainerCreate(\n      // image name\n      \"image_server_delete_before_test:latest\",\n      // container name\n      \"container_delete_before_test\",\n      // restart policy\n      iotmakerDocker.KRestartPolicyUnlessStopped,\n      // portMap\n      nat.PortMap{\n        // container port number/protocol [tpc/udp]\n        \"3000/tcp\": []nat.PortBinding{ // server original port\n          {\n            // server output port number\n            HostPort: \"9002\",\n          },\n        },\n      },\n      // mount volumes\n      []mount.Mount{\n        {\n          // bind - is the type for mounting host dir (real folder inside computer where\n          // this code work)\n          Type: iotmakerDocker.KVolumeMountTypeBindString,\n          // path inside host machine\n          Source: smallServerPathStatic,\n          // path inside image\n          Target: \"/static\",\n        },\n      },\n      // nil or container network configuration\n      networkNextAddress,\n    )\n    if err != nil {\n      panic(err)\n    }\n\n    if containerId == \"\" {\n      err = errors.New(\"container id was not generated\")\n      panic(err)\n    }\n\n    // English: container start\n    // Português: inicia o container\n    err = dockerSys.ContainerStart(containerId)\n    if err != nil {\n      panic(err)\n    }\n\n    // English: ends a goroutine\n    // Português: termina a goroutine\n    chProcessEnd \u003c- true\n\n    var page []byte\n    var found int\n    var response *http.Response\n\n    // English: contents of the static server index.html page\n    // Português: conteúdo da página index.html do servidor estático\n    var htmlIndexContent1 = []byte(\"\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003cbody\u003e\u003cp\u003eI'm alive!\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\")\n\n    err = ioutil.WriteFile(smallServerPathStaticContent, htmlIndexContent1, os.ModePerm)\n    if err != nil {\n      panic(err)\n    }\n\n    // English: takes the content from the server for testing\n    // Português: pega o conteúdo do servidor para teste\n    response, err = http.Get(\"http://localhost:9002\")\n    if err != nil {\n      panic(err)\n    }\n\n    page, err = ioutil.ReadAll(response.Body)\n    if err != nil {\n      panic(err)\n    }\n\n    // English: compare content\n    // Português: compara o conteúdo\n    found = bytes.Compare(page, htmlIndexContent1)\n    if found == 1 {\n      err = errors.New(\"small server content error\")\n      panic(err)\n    }\n\n    // English: contents of the static server index.html page\n    // Português: conteúdo da página index.html do servidor estático\n    htmlIndexContent1 = []byte(\"\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003cbody\u003e\u003cp\u003eI'm alive Dr. Frankenstein!\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\")\n\n    err = ioutil.WriteFile(smallServerPathStaticContent, htmlIndexContent1, os.ModePerm)\n    if err != nil {\n      panic(err)\n    }\n\n    // English: takes the content from the server for testing\n    // Português: pega o conteúdo do servidor para teste\n    response, err = http.Get(\"http://localhost:9002\")\n    if err != nil {\n      panic(err)\n    }\n\n    page, err = ioutil.ReadAll(response.Body)\n    if err != nil {\n      panic(err)\n    }\n\n    // English: compare content\n    // Português: compara o conteúdo\n    found = bytes.Compare(page, htmlIndexContent1)\n    if found == 1 {\n      err = errors.New(\"small server content error\")\n      panic(err)\n    }\n\n    // English: garbage collector and deletes networks and images whose name contains the term 'delete'\n    // Português: coletor de lixo e apaga redes e imagens cujo o nome contém o temo 'delete'\n    err = dockerSys.RemoveAllByNameContains(\"delete\")\n    if err != nil {\n      panic(err)\n    }\n}\n```\n\n**Português:** Monta o mesmo exemplo de servidor baseado em um repositório do \n[**github**](https://github.com/).\n\n**English:** Build a small server based on a [**github**](https://github.com/) \nrepository:\n```golang\npackage main\n\nimport (\n  \"errors\"\n  \"fmt\"\n  \"github.com/docker/docker/api/types/mount\"\n  \"github.com/docker/docker/api/types/network\"\n  \"github.com/docker/go-connections/nat\"\n  \"github.com/helmutkemper/iotmaker.docker/util\"\n  iotmakerDocker \"github.com/helmutkemper/iotmaker.docker/v1.0.0.0-RC\"\n  \"os\"\n  \"path/filepath\"\n)\n\nfunc main() {\n  var err error\n  var containerId string\n  var imageId string\n  var networkId string\n  var dockerSys *iotmakerDocker.DockerSystem\n\n  var networkAutoConfiguration *iotmakerDocker.NextNetworkAutoConfiguration\n  var networkNextAddress *network.NetworkingConfig\n\n  // English: make a channel to end goroutine\n  // Português: monta um canal para terminar a goroutine\n  var chProcessEnd = make(chan bool, 1)\n\n  // English: make a channel [optional] to print build output\n  // Português: monta o canal [opcional] para imprimir a saída do build\n  var chStatus = make(chan iotmakerDocker.ContainerPullStatusSendToChannel, 1)\n\n  // English: make a thread to monitoring and print channel data\n  // Português: monta uma thread para imprimir os dados do canal\n  go func(chStatus chan iotmakerDocker.ContainerPullStatusSendToChannel, chProcessEnd chan bool) {\n\n    for {\n      select {\n      case \u003c-chProcessEnd:\n        return\n\n      case status := \u003c-chStatus:\n        // English: remove this comment to see all build status\n        // Português: remova este comentário para vê todo o status da criação da imagem\n        fmt.Printf(\"image pull status: %+v\\n\", status)\n\n        if status.Closed == true {\n          fmt.Println(\"image pull complete!\")\n\n          // English: Eliminate this goroutine after process end\n          // Português: Elimina a goroutine após o fim do processo\n          return\n        }\n      }\n    }\n\n  }(chStatus, chProcessEnd)\n\n  // English: searches for the folder containing the test server\n  // Português: procura pela pasta contendo o servidor de teste\n  var smallServerPath string\n  smallServerPath, err = util.FileFindRecursively(\"small_test_server_port_3000\")\n  if err != nil {\n    panic(err)\n  }\n\n  // English: turns the path into an absolute path\n  // Português: transforma o caminho em caminho absoluto\n  smallServerPath, err = filepath.Abs(smallServerPath)\n  if err != nil {\n    panic(err)\n  }\n\n  // English: 'static' folder path\n  // Português: caminho da pasta 'static'\n  var smallServerPathStatic string\n  smallServerPathStatic = smallServerPath + string(os.PathSeparator) + \"static\"\n\n  // English: create a new default client. Please, use: err, dockerSys = \n  // factoryDocker.NewClient()\n  // Português: cria um novo cliente com configurações padrão. Por favor, usr: err, \n  // dockerSys = factoryDocker.NewClient()\n  dockerSys = \u0026iotmakerDocker.DockerSystem{}\n  dockerSys.ContextCreate()\n  err = dockerSys.ClientCreate()\n  if err != nil {\n    panic(err)\n  }\n\n  // English: garbage collector and deletes networks and images whose name contains the \n  // term 'delete'\n  // Português: coletor de lixo e apaga redes e imagens cujo o nome contém o temo \n  // 'delete'\n  err = dockerSys.RemoveAllByNameContains(\"delete\")\n  if err != nil {\n    panic(err)\n  }\n\n  // English: create a network named 'network_delete_before_test'\n  // Português: cria uma nova rede de nome 'network_delete_before_test'\n  networkId, networkAutoConfiguration, err = dockerSys.NetworkCreate(\n    \"network_delete_before_test\",\n    iotmakerDocker.KNetworkDriveBridge,\n    \"local\",\n    \"10.0.0.0/16\",\n    \"10.0.0.1\",\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  if networkId == \"\" {\n    err = errors.New(\"network id was not generated\")\n    panic(err)\n  }\n\n  // English: get next ip address from network, '10.0.0.2'\n  // Português: pega o próxima endereço da rede, '10.0.0.2'\n  err, networkNextAddress = networkAutoConfiguration.GetNext()\n  if err != nil {\n    panic(err)\n  }\n\n  // English: build a new image from folder 'small_test_server_port_3000'\n  // Português: monta uma imagem a partir da pasta 'small_test_server_port_3000'\n  imageId, err = dockerSys.ImageBuildFromRemoteServer(\n    \"https://github.com/helmutkemper/iotmaker.docker.util.whaleAquarium.sample.git\",\n    \"image_server_delete_before_test:latest\", // image name\n    []string{},\n    \u0026chStatus, // [channel|nil]\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  if imageId == \"\" {\n    err = errors.New(\"image ID was not generated\")\n    panic(err)\n  }\n\n  // English: building a multi-step image leaves large and useless images, taking up \n  // space on the HD.\n  // Português: construir uma imagem de múltiplas etapas deixa imagens grandes e sem \n  // serventia, ocupando espaço no HD.\n  err = dockerSys.ImageGarbageCollector()\n  if err != nil {\n    panic(err)\n  }\n\n  // English: mount and start a container\n  // Português: monta i inicializa o container\n  containerId, err = dockerSys.ContainerCreate(\n    // image name\n    \"image_server_delete_before_test:latest\",\n\n    // container name\n    \"container_delete_before_test\",\n\n    // restart policy\n    iotmakerDocker.KRestartPolicyUnlessStopped,\n\n    // port list\n    nat.PortMap{\n      // server original port\n      \"3000/tcp\": []nat.PortBinding{ \n        {\n          // new output port\n          HostPort: \"9002\", \n        },\n      },\n    },\n\n    // mount volumes\n    []mount.Mount{ \n      {\n        // bind - is the type for mounting host dir\n        // (real folder inside computer where this\n        // code work)\n        Type: iotmakerDocker.KVolumeMountTypeBindString,\n\n        // path inside host machine\n        Source: smallServerPathStatic,\n\n        // path inside image\n        Target: \"/static\",\n      },\n    },\n    networkNextAddress, // [optional] container network\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  if containerId == \"\" {\n    err = errors.New(\"container id was not generated\")\n    panic(err)\n  }\n\n  // English: container start\n  // Português: inicia o container\n  err = dockerSys.ContainerStart(containerId)\n  if err != nil {\n    panic(err)\n  }\n\n  // English: ends a goroutine\n  // Português: termina a goroutine\n  chProcessEnd \u003c- true\n\n  err = dockerSys.ContainerStop(containerId)\n  if err != nil {\n    panic(err)\n  }\n\n  err = dockerSys.ContainerRemove(containerId, true, false, false)\n  if err != nil {\n    panic(err)\n  }\n\n  // English: garbage collector and deletes networks and images whose name contains the \n  // term 'delete'\n  // Português: coletor de lixo e apaga redes e imagens cujo o nome contém o temo \n  // 'delete'\n  err = dockerSys.RemoveAllByNameContains(\"delete\")\n  if err != nil {\n    panic(err)\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelmutkemper%2Fiotmaker.docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelmutkemper%2Fiotmaker.docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelmutkemper%2Fiotmaker.docker/lists"}