DockerTest.java 1020 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import cn.reghao.devops.common.docker.DockerImpl;
  2. import com.github.dockerjava.api.model.Container;
  3. import org.junit.Test;
  4. import java.util.*;
  5. import java.util.regex.Pattern;
  6. /**
  7. * @author reghao
  8. * @date 2022-05-07 09:32:40
  9. */
  10. public class DockerTest {
  11. @Test
  12. public void dockerListTest() {
  13. Pattern pattern = Pattern.compile("^\\S*$");
  14. String str = "dfa safd";
  15. String str1 = "dfasafd";
  16. boolean matched = pattern.matcher(str).matches();
  17. System.out.println();
  18. }
  19. @Test
  20. public void dockerBuildTest() throws Exception {
  21. DockerImpl docker = new DockerImpl();
  22. String repoTag = "file:12345678";
  23. String compileHome = "/home/reghao/code/aha/tnb/file/file-service";
  24. docker.build(repoTag, compileHome);
  25. }
  26. @Test
  27. public void dockerTest() {
  28. DockerImpl docker = new DockerImpl();
  29. List<Container> list = docker.ps(true);
  30. list.forEach(container -> {
  31. container.getId();
  32. });
  33. }
  34. }