Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

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?

like image 567
BPS Avatar asked Oct 18 '25 17:10

BPS


1 Answers

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.

like image 109
six8 Avatar answered Oct 21 '25 10:10

six8