BPS
BPS

Reputation: 1678

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?

Upvotes: 4

Views: 2568

Answers (1)

six8
six8

Reputation: 2990

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.

Upvotes: 4

Related Questions