简体   繁体   中英

copy a file to a volume of a running docker container using the remote API

How do you copy a file to a volume of a running docker container using the remote API?

I know about docker cp ( https://docs.docker.com/engine/reference/commandline/cp/ ) but I would like to do this using the remote API.

I would like to do the equivalent of

docker cp path_to_local_file container:location_in_volume

Except I want to POST the file using the remote API.

I can't find anything about it in the remote API docs ( https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/ ).

Is it possible?

Use PUT archive :

PUT /containers/{container name or id}/archive?path={path in container} HTTP/1.1
Content-Type: application/x-tar


{{ TAR STREAM }}

The body of the request should be a tar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM