Docker Community Forums

Share and learn in the Docker community.

Copytocontainer

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.