Roll a Git-source container back to a kept build
const url = 'https://opfield.example.com/api/docker/nodes/550e8400-e29b-41d4-a716-446655440000/containers/example/source/rollback';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"buildId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
550e8400-e29b-41d4-a716-446655440000Example
exampleRequest Body
Section titled “Request Body”Optional JSON request body
object
A succeeded build of this source to go back to; default: the build the container ran before.
Examplegenerated
{ "buildId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}Responses
Section titled “Responses”Successful response
object
Resource object. Exact fields depend on the endpoint.
object
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
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "VALIDATION_ERROR", "message": "Request validation failed", "details": [ { "path": [ "name" ], "message": "Required" } ]}Authentication required
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "UNAUTHORIZED", "message": "Authentication required"}Forbidden
object
Error code
Human-readable error message
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).
object
Error code
Human-readable error message
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.
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "VALIDATION_ERROR", "message": "Request validation failed"}Unprocessable entity
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "UNPROCESSABLE_ENTITY", "message": "Request could not be processed"}Internal server error
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "INTERNAL_ERROR", "message": "Internal server error"}