Skip to content

Roll a Git-source container back to a kept build

POST
/api/docker/nodes/{nodeId}/containers/{containerName}/source/rollback
curl --request POST \
--url https://opfield.example.com/api/docker/nodes/550e8400-e29b-41d4-a716-446655440000/containers/example/source/rollback \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "buildId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'

Runs a build the internal registry keeps on the container again: buildId when given, otherwise the build the container ran before. The registry keeps per container the build it runs and one previous build, so a rollback can go back one build; to run older code, push a revert commit. The container is recreated from that build’s image digest with its current settings, env and secrets, the same way a build deploys it (and returned to the image it ran when the rolled-back image fails readiness); a container stopped on request stays stopped and runs the image on its next start. The source then records the rollback’s commit as deployed and keeps the build it replaced as the one to return to (roll back again to return to it). It stays on that build until a new commit on the branch, or a manual build, is built and deployed. Returns { source, build, previousBuild, note }; source.rollbackBuild in the source answer names the build a rollback would go back to now. Refused with 409 SOURCE_BUILD_IN_PROGRESS while a build of the source is queued, building or deploying. Blue/green deployments roll back with POST …/deployments/{deploymentId}/rollback, Compose Projects by applying an earlier revision. Requires docker:containers:manage on the container.

nodeId
required
string
>= 1 characters
Example
550e8400-e29b-41d4-a716-446655440000
containerName
required
string
>= 1 characters
Example
example

Optional JSON request body

Media typeapplication/json
object
buildId

A succeeded build of this source to go back to; default: the build the container ran before.

string format: uuid
Examplegenerated
{
"buildId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
}

Successful response

Media typeapplication/json
object
data
required

Resource object. Exact fields depend on the endpoint.

object
id
string
name
string
key
additional properties
Example
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Example resource",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:30:00.000Z"
}
}

Bad request

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"path": [
"name"
],
"message": "Required"
}
]
}

Authentication required

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

Forbidden

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "FORBIDDEN",
"message": "Insufficient permissions"
}

The container has no Git source (SOURCE_BINDING_NOT_FOUND), or buildId is not a build of its source (SOURCE_ROLLBACK_BUILD_NOT_FOUND).

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "VALIDATION_ERROR",
"message": "Request validation failed"
}

Nothing was changed. SOURCE_ROLLBACK_UNAVAILABLE: no previous build is kept (push a revert commit instead). SOURCE_BUILD_IN_PROGRESS: a build of the source is queued, building or deploying (details.buildId, details.status); wait or cancel it. SOURCE_ROLLBACK_BUILD_NOT_SUCCEEDED, SOURCE_ROLLBACK_BUILD_NOT_KEPT, SOURCE_ROLLBACK_BUILD_NOT_APPROVED, SOURCE_ROLLBACK_BUILD_RUNNING: buildId names a build that is not succeeded, whose image the registry no longer keeps, that the vulnerability policy did not approve, or that the container already runs (details name the value found and the one expected). SOURCE_ROLLBACK_FAILED: the rolled-back image did not become ready and the container runs its previous image again (the message carries the container state). BUILD_ROLLOUT_IN_PROGRESS: a build rollout took the container meanwhile.

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "VALIDATION_ERROR",
"message": "Request validation failed"
}

Unprocessable entity

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "UNPROCESSABLE_ENTITY",
"message": "Request could not be processed"
}

Internal server error

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "INTERNAL_ERROR",
"message": "Internal server error"
}