@@ -60,7 +60,7 @@ func Pull(image string) error {
6060 cmd .Stderr = os .Stderr
6161 }
6262
63- logger .Debugf ("running command: %s" , cmd )
63+ logger .Debugf ("run command: %s" , cmd )
6464 err := cmd .Run ()
6565 if err != nil {
6666 return errors .Wrap (err , "running docker command failed" )
@@ -112,7 +112,7 @@ func ConnectToNetwork(containerID, network string) error {
112112 errOutput := new (bytes.Buffer )
113113 cmd .Stderr = errOutput
114114
115- logger .Debugf ("output command: %s" , cmd )
115+ logger .Debugf ("run command: %s" , cmd )
116116 if err := cmd .Run (); err != nil {
117117 return errors .Wrapf (err , "could not attach container to the stack network (stderr=%q)" , errOutput .String ())
118118 }
@@ -142,19 +142,15 @@ func InspectContainers(containerIDs ...string) ([]ContainerDescription, error) {
142142 return containerDescriptions , nil
143143}
144144
145- // Exec function executes command inside of the container
146- func Exec (containerName string , args ... string ) ([]byte , error ) {
147- cmdArgs := []string {"exec" , "-t" , containerName }
148- cmdArgs = append (cmdArgs , args ... )
149-
150- cmd := exec .Command ("docker" , cmdArgs ... )
145+ // Copy function copies resources from the container to the local destination.
146+ func Copy (containerName , containerPath , localPath string ) error {
147+ cmd := exec .Command ("docker" , "cp" , containerName + ":" + containerPath , localPath )
151148 errOutput := new (bytes.Buffer )
152149 cmd .Stderr = errOutput
153150
154- logger .Debugf ("output command: %s" , cmd )
155- output , err := cmd .Output ()
156- if err != nil {
157- return nil , errors .Wrapf (err , "exec failed (stderr=%q)" , errOutput .String ())
151+ logger .Debugf ("run command: %s" , cmd )
152+ if err := cmd .Run (); err != nil {
153+ return errors .Wrapf (err , "could not copy files from the container (stderr=%q)" , errOutput .String ())
158154 }
159- return output , nil
155+ return nil
160156}
0 commit comments