•
•
•
•
•
•
•
•
•
•
•
–
•
–
•
–
–
•
–
•
docker run --name my-ubuntu-container –it ubuntu
•
docker ps
•
docker stop my-ubuntu-container
•
docker ps my-ubuntu-container
•
•
DockerClient dockerClient = DefaultDockerClient.fromEnv().build();
// Pull MySQL image
String imageName = "mysql:5.7.21";
dockerClient.pull(imageName); // Pull the MySQL image
// Create and start a MySQL container with exposed port
ContainerConfig containerConfig = ContainerConfig.builder()
.image(imageName)
.exposedPorts("3306")
.build();
ContainerCreation creation = dockerClient.createContainer(containerConfig);
dockerClient.startContainer(creation.id());
// Stop and remove container
dockerClient.stopContainer(containerId, 30);
dockerClient.removeContainer(containerId);
@Before
@After
Demo
•
•
•
•
•
•
Demo
•
–
–
•
–
•
–
–
•
–
–
•
–
–
Demo
•
–
–
–
•
–
–
Dockerfile
FROM mariadb:5.5.44
ADD run_db init_db dump.sql /tmp/
RUN chmod u+x /tmp/init_db /tmp/run_db
# init_db will import the dump, then stop mysqld, and finally package
# the /var/lib/mysql directory to 'default_mysql_db.tar.gz‘
RUN /tmp/init_db
# run_db starts mysqld, but first it checks to see if the /var/lib/mysql
# directory is empty. if it is, it is seeded with
# 'default_mysql_db.tar.gz' before the mysql is fired up
ENTRYPOINT "/tmp/run_db"
Demo
•
–
–
•
–
–
Demo
•
–
–
–
–
•
–
–
–
–
•
–
–
–
Demo
•
–
–
•
–
–
•
–
–
•
–
•
•
•
Demo
•
•
•
•
•
•
•
•
•
•
•
Dev Day 2019: Mirko Seifert – Next Level Integration Testing mit Docker und TestContainers

Dev Day 2019: Mirko Seifert – Next Level Integration Testing mit Docker und TestContainers