# Copytocontainer

**URL:** <https://forums.docker.com/t/copytocontainer/72520>\
**Category:** General\
**Created:** [April 4, 2019, 12:54pm UTC](https://forums.docker.com/t/copytocontainer/72520 "2019-04-04T12:54:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitkag](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rohitkag](https://forums.docker.com/u/rohitkag)\
**Post date:** [April 4, 2019, 12:54pm UTC](https://forums.docker.com/t/copytocontainer/72520/1 "2019-04-04T12:54:42Z")

</div>

Hello,

For my application docker cp works perfectly fine, but when I try to do the same using copy to container, it doesn’t work.

Error: No such container:path: 497cf9d0c0a84803fd9eb4d76f032296ebfb45b5ff2f9833f697757c1f312014:/authorized\_keys

Snapshot of code:  
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})  
141 if err != nil {  
142 return err  
144 }  
148  
149 for \_, container := range containers {  
150 if strings.Contains(container.Names[0], “etx”) {

154 err := cli.CopyToContainer(context.Background(), container.ID, “/test”, bytes.NewReader(byte(“content”)) , types.CopyToContainerOptions{})  
155 if err!= nil {  
156 log.Println(err)  
157 return err  
158 }  
160 }  
161 }

if I take the container.id using docker cp, it works perfeclty fine.

please let me know if any details are missing. I will be happy to share.
