Help us learn about your current experience with the documentation. Take the survey.
Dockerfiles API
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
GitLab 提供了一个 API 端点,用于访问整个实例可用的 Dockerfile 模板。
默认模板定义在 GitLab 仓库的
vendor/Dockerfile 中。
访客(Guest)角色的用户无法访问 Dockerfile 模板。更多信息,请参阅 项目和组可见性。
覆盖 Dockerfile API 模板
- Tier: Premium, Ultimate
- Offering: GitLab Self-Managed, GitLab Dedicated
在 GitLab 高级版和旗舰版 中,GitLab 实例管理员可以在 管理员区域 中覆盖模板。
列出 Dockerfile 模板
获取所有 Dockerfile 模板。
GET /templates/dockerfiles示例请求:
curl "https://gitlab.example.com/api/v4/templates/dockerfiles"示例响应:
[
{
"key": "Binary",
"name": "Binary"
},
{
"key": "Binary-alpine",
"name": "Binary-alpine"
},
{
"key": "Binary-scratch",
"name": "Binary-scratch"
},
{
"key": "Golang",
"name": "Golang"
},
{
"key": "Golang-alpine",
"name": "Golang-alpine"
},
{
"key": "Golang-scratch",
"name": "Golang-scratch"
},
{
"key": "HTTPd",
"name": "HTTPd"
},
{
"key": "Node",
"name": "Node"
},
{
"key": "Node-alpine",
"name": "Node-alpine"
},
{
"key": "OpenJDK",
"name": "OpenJDK"
},
{
"key": "PHP",
"name": "PHP"
},
{
"key": "Python",
"name": "Python"
},
{
"key": "Python-alpine",
"name": "Python-alpine"
},
{
"key": "Python2",
"name": "Python2"
},
{
"key": "Ruby",
"name": "Ruby"
},
{
"key": "Ruby-alpine",
"name": "Ruby-alpine"
},
{
"key": "Rust",
"name": "Rust"
},
{
"key": "Swift",
"name": "Swift"
}
]单个 Dockerfile 模板
获取单个 Dockerfile 模板。
GET /templates/dockerfiles/:key| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
key |
string | 是 | Dockerfile 模板的 key |
示例请求:
curl "https://gitlab.example.com/api/v4/templates/dockerfiles/Binary"示例响应:
{
"name": "Binary",
"content": "# This file is a template, and might need editing before it works on your project.\n# This Dockerfile installs a compiled binary into a bare system.\n# You must either commit your compiled binary into source control (not recommended)\n# or build the binary first as part of a CI/CD pipeline.\n\nFROM buildpack-deps:buster\n\nWORKDIR /usr/local/bin\n\n# Change `app` to whatever your binary is called\nAdd app .\nCMD [\"./app\"]\n"
}