How can I copy files from system to Docker container using docker API?

316 Views Asked by At

I am creating a web project using java. Here I am downloading a file from web and I must need to transfer the downloaded file to the docker container. I am using the docker API

PUT /containers/{id}/archive https://docs.docker.com/engine/api/v1.41/#operation/PutContainerArchive

But, this gives error like below:

For copying a simple text file:
{
    "message": "Error processing tar file(exit status 1): unexpected EOF"
}
For copying a tar file:
{
    "message": "Error processing tar file(exit status 1): archive/tar: invalid tar header"
}

Here am using docker API because I must need to do copying the files to the contianer using Java. Understand my case and give your suggestions.

0

There are 0 best solutions below