Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created method which copy file from repository to container #378

Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ ExecResult execInContainer(Charset outputCharset, String... command)

InspectContainerResponse getContainerInfo();

void copyFileToContanier(String localPath, String containerPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using MountableFile instead of String localPath

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo as well


void setExposedPorts(List<Integer> exposedPorts);

void setPortBindings(List<String> portBindings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,27 @@ public ExecResult execInContainer(String... command)
return execInContainer(UTF8, command);
}

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move the JavaDoc to Container interface

*
* Method allow to copy file which we have in our repository to docker container
*
* @param localPath path with file which we would like to place in container
* @param containerPath path where we want to copy file
*/
@Override
public void copyFileToContanier(String localPath, String containerPath){

if (!isRunning()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since isRunning calls Docker API, I would remove this check and catch an exception from .exec()

throw new IllegalStateException("Container is not running so copy cannot be run");
}

this.dockerClient
.copyArchiveToContainerCmd(this.containerId)
.withHostResource(localPath)
.withRemotePath(containerPath)
.exec();
}

/**
* {@inheritDoc}
*/
Expand Down