I am trying to copy files to a created container (not running), using the docker go SDK
snippet:
func (c *DkClient) CopyToContainer(containerID string, tarPath string) error {
log.Debug().Msgf("Copying files to container %s", containerDirectory)
tarStream, err := os.Open(tarPath)
if err != nil {
return err
}
c.client.Cop
err = c.client.CopyToContainer(
context.Background(),
containerID,
containerDirectory,
tarStream,
container.CopyToContainerOptions{AllowOverwriteDirWithFile: true},
)
if err != nil {
log.Error().Err(err).Msgf("failed to copy to Docker container")
return fmt.Errorf("failed to copy submission to container")
}
return nil
}
But I get the following error
Error response from daemon: Could not find the file /home/test/test.tar.gz in container ....
If I use docker cp it works
docker cp .\test.tar.gz <contId>:/home/test/test.tar.gz
Successfully copied 8.19kB to :/home/test/test.tar.gz
Anyone know why this is happening thanks !!