如何使用 Docker API 删除容器内的文件
How to remove files inside a container using the Docker API
请指教,如何使用DockerAPI删除容器内的文件?
我试过这样做,但是不行
curl --location --request POST 'http://192.168.1.55:5555/containers/{id}/exec' \
--header 'Content-Type: application/json' \
--data-raw '{
"Cmd": [
"/bin/sh",
"-c",
"'rm -rf /files/*'"
]
}'
按照Docker API doc"To exec a command in a container, you first need to create an exec instance, then start it. These two API endpoints are wrapped up in a single command-line command, docker exec."这样,得到响应后必须运行新POST请求/exec/{id}/start
请指教,如何使用DockerAPI删除容器内的文件? 我试过这样做,但是不行
curl --location --request POST 'http://192.168.1.55:5555/containers/{id}/exec' \
--header 'Content-Type: application/json' \
--data-raw '{
"Cmd": [
"/bin/sh",
"-c",
"'rm -rf /files/*'"
]
}'
按照Docker API doc"To exec a command in a container, you first need to create an exec instance, then start it. These two API endpoints are wrapped up in a single command-line command, docker exec."这样,得到响应后必须运行新POST请求/exec/{id}/start