LinuxCommandLibrary

docker-update

Update a container's resources and configuration

TLDR

Update restart policy to apply when a specific container exits

$ docker update --restart=[always|no|on-failure|unless-stopped] [container_name]
copy

Update the policy to restart up to three times a specific container when it exits with non-zero exit status
$ docker update --restart=on-failure:3 [container_name]
copy

Update the number of CPUs available to a specific container
$ docker update --cpus [count] [container_name]
copy

Update the memory limit in [M]egabytes for a specific container
$ docker update [[-m|--memory]] [limit]M [container_name]
copy

Update the maximum number of process IDs allowed inside a specific container (use -1 for unlimited)
$ docker update --pids-limit [count] [container_name]
copy

Update the amount of memory in [M]egabytes a specific container can swap to disk (use -1 for unlimited)
$ docker update --memory-swap [limit]M [container_name]
copy

SYNOPSIS

As docker-update is not a standard Docker CLI command, there is no fixed, universal synopsis. Its invocation depends entirely on how the custom script is implemented. However, a conceptual synopsis for such a script, often placed in the system's PATH, might resemble:
docker-update [OPTIONS] [CONTAINER_NAMES...]
or
docker-update [ACTION]

PARAMETERS

-a, --all
    (Conceptual) To update all known containers managed by the script.

-c , --container
    (Conceptual) To specify a particular container or list of containers to update.

-i , --image
    (Conceptual) To pull and update based on a specific image name or tag.

--no-recreate
    (Conceptual) To only pull new images without stopping/restarting containers.

--dry-run
    (Conceptual) To show what would be updated without performing any actual changes.

-h, --help
    (Conceptual) To display script-specific help information.

DESCRIPTION

The command docker-update is not a native or standard command provided by the Docker CLI. Instead, it typically refers to a custom shell script or automation tool created by users or system administrators to simplify the process of updating Docker images and recreating or updating running containers. The primary purpose of such a script is to automate the manual steps involved in deploying new versions of containerized applications.

This often includes:

  • Pulling the latest versions of Docker images from registries.
  • Stopping existing containers that use older images.
  • Removing stopped containers.
  • Creating and starting new containers using the freshly pulled images, often ensuring data persistence via volumes.
  • Optionally, handling cleanup of old, unused images.

Because docker-update is user-defined, its exact behavior, options, and parameters vary greatly depending on its implementation. It serves as a common conceptual name for the automated maintenance of Docker environments, bridging the gap for a full "update everything" command that Docker's native CLI does not provide out-of-the-box for all scenarios.

CAVEATS

  • Not a Standard Command: The most significant caveat is that docker-update is not part of the official Docker CLI. Its existence and functionality depend entirely on a user-defined script.
  • Variability: Behavior, options, and robustness differ vastly between implementations. A script found online may not work as expected or could contain errors.
  • Security Risks: Running arbitrary docker-update scripts from unknown sources can pose significant security risks, as they often require elevated permissions to interact with the Docker daemon and could execute malicious commands.
  • Dependency Management: Custom scripts require maintenance. Changes in Docker's underlying commands or APIs might break older scripts.
  • Error Handling: Robust error handling is often lacking in simple custom scripts, potentially leaving containers in an inconsistent state if an update fails midway.

COMMON SCRIPTING PATTERNS

A typical docker-update script often involves iterating through a list of container names or Docker Compose project directories. For each, it would attempt to pull the latest image, then gracefully stop and remove the old container, and finally re-launch a new container with the updated image, ensuring proper volume mounts and network configurations are preserved. Some more advanced scripts might include rollback capabilities or health checks after restarting. Users often place these scripts in a directory included in their system's PATH, such as /usr/local/bin or ~/bin, and ensure they are executable.

HISTORY

The concept behind a "docker-update" command emerged from the need for convenient, one-shot automation in managing Docker deployments. While Docker provides granular commands for each step (pull, stop, rm, run), there was no single, high-level command to orchestrate the entire image-update-container-recreation lifecycle for individual containers or small groups. This led many users and system administrators to develop custom shell scripts (often named docker-update or similar) to bundle these actions, especially for personal servers, small projects, or non-orchestrated environments where tools like Kubernetes or Docker Swarm were overkill. The usage of such scripts became a common pattern before more comprehensive orchestration and deployment tools became widely adopted for broader use cases.

SEE ALSO

docker pull: Downloads a Docker image from a registry., docker stop: Stops one or more running containers., docker rm: Removes one or more stopped containers., docker run: Creates and starts a new container from an image., docker create: Creates a new container but does not start it., docker update: Updates configuration (e.g., restart policy, resources) of one or more running containers (not images)., docker compose pull: Pulls service images defined in a Docker Compose file., docker compose up: Creates, starts, and runs containers as defined in a Docker Compose file, often with an implicit pull of new images., docker ps: Lists running containers., docker images: Lists Docker images., docker volume: Manages Docker volumes (crucial for data persistence).

Copied to clipboard