A Test Kitchen Driver(and Transport) for Docker command line interface.
This plugin is created with only Docker CLI functions.
We can test on the environment that has no extra software such as sshd
.
Test-Kitchen (>= 1.3)
Docker (>= 1.8)
This driver uses docker exec
and docker cp
to upload some files to the containers.
tar (GNU Tar)
gem install kitchen-docker_cli
or put Gemfile
in your project directory.
source 'https://rubygems.org'
gem 'kitchen-docker_cli'
and
bundle install
At first, put your .kitchen(.local).yml
like this.
---
driver:
name: docker_cli
transport:
name: docker_cli
platforms:
- name: ubuntu-12.04
- name: centos-6.4
suites:
- name: default
run_list:
attributes:
The Docker image's path.
The default value get from platform.name
.
Examples:
image: marcy/amzn
The Docker image's platform.
The default value get from platform.name
.
Examples:
platform: centos
The command to be executed at docker run
.
The default value is sh -c 'while true; do sleep 1d; done;'
.
Examples:
command: /bin/bash
Adds RUN
command(s) to Dockerfile
.
The default value is nil
.
Examples:
run_command:
- yum -y install httpd
- service httpd start
Adds ENV
command(s) to Dockerfile
.
The default value is nil
.
Examples:
environment:
http_proxy: http://proxy.example.com:8080/
LANG: ja_JP.UTF-8
Pass the basedir as the Docker build context: 'docker build
Set option --pull
to the defined value on docker build
.
The default value is nil which is currently interpreted as false
by Docker.
build_pull: true
Not use the cached image on docker build
.
The default value is false
.
Examples:
no_cache: true
Skip the automatically preparation in the step to building Docker image.
(i.e. Just pulling the image)
The default value is false
.
Examples:
skip_preparation: true
Give extended privileges to the suite container.
The default value is false
.
Examples:
privileged: true
Define the seccomp security profile to use.
The default value is nil
.
Examples:
security_opt: seccomp=unconfined
Set the name of container to link other container(s).
Examples:
container_name: web
Use instance name to container_name.
The default value is false
.
Examples:
instance_container_name: true
Improve destroy action when containers have defined names.
When enabled, "kitchen destroy" will always try to remove suite containers with their name (if defined by container_name or instance_container_name options) in addition to with the id defined in the current state. This allows a clean removal of containers even if the state is corrupted or was removed.
The default value is true
.
Examples:
destroy_container_name: false
Set the Network mode for the container.
bridge
: creates a new network stack for the container on the docker bridgenone
: no networking for this containercontainer:<name|id>
: reuses another container network stackhost
: use the host network stack inside the containerExamples:
network: host
Set hostname to container.
Examples:
hostname: example.local
Use instance name to hostname.
The default value is false
.
Examples:
instance_host_name: true
The IP addresses of your DNS servers.
dns: 8.8.8.8
dns:
- 8.8.8.8
- 8.8.4.4
Set container_name
(and alias) of other container(s) that connect from the suite container.
Examples:
link: mysql:db
link:
- mysql:db
- redis:kvs
Publish a container's port or a range of ports to the host.
The default value is nil
.
Examples:
publish: 80
publish:
- 80:8080
- 22:2222
Publish all exposed ports to the host interfaces. This option used to communicate between some containers.
The default value is false
.
Examples:
publish_all: true
Expose a port or a range of ports from the container without publishing it to your host.
The default value is nil
.
Examples:
expose: 80
expose:
- 80
- 22
Add additional lines to /etc/hosts
.
Examples:
add_host: myhost:127.0.0.1
add_host:
- myhost:127.0.0.1
- yourhost:123.123.123.123
Adds data volume(s) to the container.
Examples:
volume: /data
volume:
- /tmp:/tmp
- <%= Dir::pwd %>:/var:rw
Mount data volume(s) from other container(s).
Examples:
volumes_from: container_name
volumes_from:
- container_a
- container_b
Attach a filesystem mount to the container.
Examples:
mount: type=volume,source=my-volume,destination=/path/in/container
Create test image using a supplied Dockerfile, instead of the default Dockerfile created.
And it can be written as ERB template.
For best results, please:
dockerfile: my/dockerfile
Template variables for the custom Dockerfile.
Example:
driver:
image: marcy/hoge
dockerfile: dockerfile.erb
dockerfile_vars:
envs:
LANG: ja_JP.UTF-8
cmds:
- yum -y install httpd
FROM <%= config[:image] %>
<% @envs.each do |k,v| %>
ENV <%= k %> <%= v %>
<% end %>
<% @cmds.each do |c| %>
RUN <%= c %>
<% end %>
FROM marcy/hoge
ENV LANG ja_JP.UTF-8
RUN yum -y install httpd
Constrain the memory available.
memory_limit: 256m
Change the priority of CPU Time.
This option with value 0 indicates that the running container has access to all 1024 (default) CPU shares.
cpu_shares: 512
If you use the LXC Driver of Docker (CircleCI), please set true
The default value is false
lxc_driver: true
Base of docker
command.
The default value is docker
Example:
docker_base: sudo /path/to/docker
Base of lxc-attach
command.
This option is used on LXC driver only.
The default value is sudo lxc-attach
Example:
docker_base: sudo /path/to/lxc-attach
Base of lxc-console
command.
This option is used on LXC driver only.
The default value is sudo lxc-console
Example:
docker_base: sudo /path/to/lxc-console
A script or shell command to run locally prior to creating the container. Used to prep the build environment, e.g. performing a login to a private docker repository where the test images are housed.
Example:
pre_create_command: ./path/to/script.sh
If true, it will not use docker_cp to copy files into the container but the old classic way of a docker exec "tar ...".
This option can be used as a workaround for this kind of bugs: https://github.com/moby/moby/issues/38252.
It is better used in system config than in each cookbook as it is closely related to the system configuration.
Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)Created and maintained by Masashi Terui (marcy9114@gmail.com)
Apache 2.0 (see LICENSE)