{"id":16302821,"url":"https://github.com/himenon/docker-typescript-openapi","last_synced_at":"2026-04-16T08:31:40.725Z","repository":{"id":43303067,"uuid":"467487643","full_name":"Himenon/docker-typescript-openapi","owner":"Himenon","description":"TypeScript implementations generated from Docker OpenAPI","archived":false,"fork":false,"pushed_at":"2022-03-09T06:40:47.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-16T12:16:30.921Z","etag":null,"topics":["docker","nodejs","openapi","swagger","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Himenon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-08T11:41:09.000Z","updated_at":"2022-03-09T06:31:53.000Z","dependencies_parsed_at":"2022-09-01T18:10:18.344Z","dependency_job_id":null,"html_url":"https://github.com/Himenon/docker-typescript-openapi","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fdocker-typescript-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fdocker-typescript-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fdocker-typescript-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fdocker-typescript-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Himenon","download_url":"https://codeload.github.com/Himenon/docker-typescript-openapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166945,"owners_count":21058480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["docker","nodejs","openapi","swagger","typescript"],"created_at":"2024-10-10T20:59:04.186Z","updated_at":"2026-04-16T08:31:40.683Z","avatar_url":"https://github.com/Himenon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @himenon/docker-typescript-openapi\n\n```bash\nyarn add @himenon/docker-typescript-openapi\n```\n\n## Usage\n\n### Get Docker Image\n\n[Example Code](example/get-docker-images.ts)\n\n```ts\nimport { Client } from \"@himenon/docker-typescript-openapi/v1.41\";\nimport * as ApiClientImpl from \"@himenon/docker-typescript-openapi/api-client-impl\";\nimport * as fs from \"fs\";\n\nconst main = async () =\u003e {\n  const apiClientImpl = ApiClientImpl.create({\n    socketPath: \"/var/run/docker.sock\",\n  });\n  const client = new Client(apiClientImpl, \"/v1.41\");\n\n  fs.mkdirSync(\"debug\", { recursive: true });\n\n  const filename1 = \"debug/docker-images.json\";\n  const imageList = await client.ImageList({\n    parameter: {},\n  });\n  fs.writeFileSync(filename1, JSON.stringify(imageList, null, 2), \"utf-8\");\n  console.log(`Output: ${filename1}`);\n\n  const filename2 = \"debug/docker-containers.json\";\n  const containerList = await client.ContainerList({\n    parameter: {},\n  });\n  fs.writeFileSync(filename2, JSON.stringify(containerList, null, 2), \"utf-8\");\n  console.log(`Output: ${filename2}`);\n};\n\nmain();\n```\n\n### Output Logs\n\n[Example Code](example/get-container-log.ts)\n\n```ts\nimport { Client } from \"@himenon/docker-typescript-openapi/v1.41\";\nimport * as ApiClientImpl from \"@himenon/docker-typescript-openapi/api-client-impl\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as stream from \"stream\";\n\nconst main = async () =\u003e {\n  const apiClientImpl = ApiClientImpl.create({\n    socketPath: \"/var/run/docker.sock\",\n  });\n  const client = new Client(apiClientImpl, \"/v1.41\");\n\n  fs.mkdirSync(\"debug\", { recursive: true });\n  const currentDir = path.resolve(\"example\");\n  const containerName = \"create-from-api\";\n\n  const alreadyUsedContainers = await client.ContainerList({\n    parameter: {\n      all: true,\n      filters: `name=${containerName}`,\n    },\n  });\n  const removeTasks = alreadyUsedContainers.map(async container =\u003e {\n    if (!container.Id) {\n      return;\n    }\n    if (container.State === \"running\") {\n      await client.ContainerStop({\n        parameter: {\n          id: container.Id,\n        },\n      });\n    }\n\n    await client.ContainerDelete({\n      parameter: {\n        id: container.Id,\n      },\n    });\n  });\n  await Promise.all(removeTasks);\n  const filename1 = \"debug/docker-create-container.json\";\n  const container = await client.ContainerCreate({\n    headers: {\n      \"Content-Type\": \"application/json\",\n    },\n    parameter: {\n      name: containerName,\n    },\n    requestBody: {\n      Image: \"golang:1.17\",\n      WorkingDir: \"/app\",\n      AttachStdin: true,\n      AttachStdout: true,\n      AttachStderr: true,\n      OpenStdin: true,\n      Cmd: [\"ls\"],\n      HostConfig: {\n        Mounts: [\n          {\n            Type: \"bind\",\n            Source: currentDir,\n            Target: \"/app\",\n          },\n        ],\n      },\n    },\n  });\n\n  fs.writeFileSync(filename1, JSON.stringify(container, null, 2), \"utf-8\");\n  console.log(`Output: ${filename1}`);\n\n  await client.ContainerStart({\n    parameter: {\n      id: container.Id,\n    },\n  });\n\n  const logStream = new stream.PassThrough();\n  logStream.on(\"data\", chunk =\u003e {\n    console.log(chunk.toString(\"utf-8\"));\n  });\n\n  await client.ContainerLogs(\n    {\n      headers: {\n        Accept: \"application/json\",\n      },\n      parameter: {\n        id: container.Id,\n        stdout: true,\n        stderr: true,\n        follow: true,\n        tail: \"all\",\n      },\n    },\n    {\n      isStream: true,\n      onResponse: res =\u003e {\n        res.on(\"data\", chunks =\u003e {\n          logStream.write(chunks);\n        });\n        res.on(\"end\", () =\u003e {\n          logStream.end();\n        });\n      },\n    },\n  );\n};\n\nmain().catch(error =\u003e {\n  console.error(error);\n  process.exit(1);\n});\n```\n\n## Build\n\n```ts\nyarn run build\n```\n\n## OpenAPI Source for Docker\n\n- \u003chttps://docs.docker.com/engine/api\u003e\n\n## OpenAPI TypeScript Code Generator\n\n- [@himenon/openapi-typescript-code-generator](https://github.com/Himenon/openapi-typescript-code-generator)\n\nYou can also just use the type definition\n\n## Use Another Version\n\nEdit [config.ts](./scripts/config.ts)\n\n## Debugging\n\nDocker Engine Logs\n\n**Mac OS**\n\n```bash\ntail -f ~/Library/Containers/com.docker.docker/Data/log/host/com.docker.driver.amd64-linux.log\n```\n\n## LICENCE\n\n[@Himenon/docker-typescript-openapi](https://github.com/Himenon/docker-typescript-openapi)・MIT\n\n## Inspired By\n\n- https://github.com/apocas/dockerode\n- https://github.com/apocas/docker-modem\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimenon%2Fdocker-typescript-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhimenon%2Fdocker-typescript-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimenon%2Fdocker-typescript-openapi/lists"}