This document discusses how Docker can help with testing by exploring existing Dockerfiles, using dockerized tools, and creating a testing infrastructure with Docker. Some key points include:
- Docker allows easy installation, updating, and switching of tool versions on one machine through containerization.
- Existing Dockerfiles can provide examples for configuring tools. Docker Hub and Docker Store offer existing dockerized tool images.
- Internal tool ports can be exposed and accessed on the host machine. Custom images can also be built.
- A CI system with docker-compose can stand up project instances automatically for testing.
4. How Docker can help testing
- Exploration of existing Dockerfiles.
- Using dockerized tools.
- Creation of testing infrastructure based on Docker.
...you will also become more acquainted with Linux shell and shell/bash scripting.
5. Explorating existing Dockerfiles
You can find some useful information how to setup and configure some tools even by exploration of
existing Dockerfiles that can be found on Docker Hub, Github/Bitbucket inside Docker image repositories.
7. Advantages
● Easy installation and configuration.
● Ability to use a few different tool versions on one machine.
● Easy updating or switching between versions.
● Ability to easily switch tools between ports.
● Ability to use tools and services which aren’t supported by your OS.
8. Disadvantages
● Some functionality can work not as expected (e.g., there are some troubles in
using Docker inside dockerized Jenkins CI).
● Permissions for files created by Docker. By default, all the files and directories
created inside a Docker container and shared to host machine are owned by
Docker.
● Not all versions can be available for tools that you need.
● Some performance losses are possible on macOS and Windows systems
because of using Docker inside a virtual machine.
9. Where to search for existing tool images?
You can find existing Docker images using Docker registry:
● Docker Hub - the main Docker registry. https://hub.docker.com/
● Docker Store - place for trusted and Enterprise Ready Containers, Plugins,
and Docker Editions. https://store.docker.com/
10. Accessing dockerized tools by ports.
- Internal Docker container ports can be exposed to any free host port.
- Internal tool’s ports inside containers are to be exposed as a host machine
ports using docker run “-p” / ”-P” command options.
- Tools or services inside containers can be used through exposed ports by
calling needed port on host machine.
12. Advantages
- Full control on software versions.
- Lightweight images.
- Configuration flexibility.
Disadvantages
- Can be time consuming, especially on the beginning.
- Commonly useless if you don’t need additional customization.
13. Ways of creating your own image
● Local image building and using on the same machine.
● Local image building and pushing it to Docker registry.
● Remote image building using Docker registry.
...anyway you need to start from writing a Dockerfile.
16. Preconditions
- You need to have some CI system.
- There is a way to up project instances without human interactions on CI
system.
- It's preferable to have the whole project on docker.
- Understanding of docker-compose extending logic will be very helpful.
17. Possible docker-compose files structure.
● docker-compose.yml - basic configurations and services that are needed
for all environments.
● docker-compose.override.yml - additional configurations and services
that are commonly used for local environments.
● docker-compose.{whatever}.yml - additional configurations and
services that are needed for other environments.