Update a docker run container with a conservative workflow.
Require both of these from the user:
container_namerecreate_commandTreat recreate_command as the source of truth. Do not try to reconstruct missing flags from docker inspect.
Support only containers originally managed by docker run.
Do not use this skill for:
docker composedocker system pruneAlways compare image Id values, not repo digests.
Use this exact logic:
```bash
docker inspect -f '{{.Image}}'
```
recreate_command.```bash
docker pull
```
```bash
docker image inspect
```
Before any destructive action, restate the exact recreate command that will be used.
If recreate_command is missing, ambiguous, or not clearly a docker run command, stop and ask the user to provide a valid full command.
If the image cannot be extracted from recreate_command, stop and ask the user to provide the image explicitly inside the command.
Never silently modify the recreate command.
Prefer this sequence when update is needed:
docker stop <container_name>
docker rm <container_name>
<recreate_command>
Before using it, verify all of the following:
docker runIf the command includes an inline container command after the image, preserve it exactly.
If the command is multiline, preserve it exactly.
docker stop docker rm recreate_command```bash
docker ps --filter name=
docker inspect
docker logs --tail 100
```
healthy, starting, or absent.Use the bundled script when you want a deterministic check/apply flow:
python3 scripts/update_docker_run_container.py \
--container-name <container_name> \
--recreate-command '<full docker run command>'
Add --apply only when the user has approved the exact recreate command and actual recreation should happen.
The script will:
recreate_commandWhen reporting results, include:
Input:
container_name: my-containerrecreate_command:```bash
docker run -d --network host --name my-container --restart unless-stopped -v example_data:/data -v example_certs:/etc/ssl/certs -e DB_HOST=
```
Expected behavior:
example/image:latestWhen users ask to "update container X", prefer asking for the original docker run command unless it is already documented in memory or provided in the current request.
If the user has a known fixed recreate command for a specific container, prefer using that exact command unchanged.
共 1 个版本