Skip to content

Commit 83bf71a

Browse files
committed
Merge pull request #9 from gregf/memory_limit
Adds support for using dockers memory limiter.
2 parents 0cc1836 + d2e7405 commit 83bf71a

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# <a name="title"></a> Kitchen::Docker
1+
# Kitchen::Docker
22

33
A Test Kitchen Driver for Docker.
44

5-
## <a name="requirements"></a> Requirements
5+
## Requirements
66

77
* [Docker][docker_getting_started]
88

9-
## <a name="issues"></a> Known Issues
9+
## Known Issues
1010

1111
* Upstart is neutered due to [this issue][docker_upstart_issue].
1212

13-
## <a name="installation"></a> Installation and Setup
13+
## Installation and Setup
1414

1515
Please read the [Driver usage][driver_usage] page for more details.
1616

@@ -32,16 +32,16 @@ platforms:
3232
- recipe[yum]
3333
```
3434

35-
## <a name="config"></a> Configuration
35+
## Configuration
3636

37-
### <a name="config-image"></a> image
37+
### image
3838

3939
The Docker image to use as the base for the suite containers. You can find
4040
images using the [Docker Index][docker_index].
4141

4242
The default value is `base`, an official Ubuntu [image][docker_default_image].
4343

44-
### <a name="config-platform"></a> platform
44+
### platform
4545

4646
The platform of the chosen image. This is used to properly bootstrap the
4747
suite container for Test Kitchen. Kitchen Docker currently supports:
@@ -51,7 +51,7 @@ suite container for Test Kitchen. Kitchen Docker currently supports:
5151

5252
The default value is `ubuntu`.
5353

54-
### <a name="config-require-chef-omnibus"></a> require\_chef\_omnibus
54+
### require\_chef\_omnibus
5555

5656
Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
5757
installed. There are several different behaviors available:
@@ -67,7 +67,14 @@ installed. There are several different behaviors available:
6767

6868
The default value is `true`.
6969

70-
### <a name="config-forward"></a> forward
70+
### memory
71+
72+
Sets the memory limit for the container. The value must be set in bytes.
73+
If not set it defaults to dockers default settings.
74+
75+
default value is `nil`.
76+
77+
### forward
7178

7279
Suite container port(s) to forward to the host machine. You may specify
7380
the host (public) port in the mappings, if not, Docker chooses for you.
@@ -84,7 +91,7 @@ forward:
8491
- 80:8080
8592
```
8693

87-
## <a name="development"></a> Development
94+
## Development
8895

8996
* Source hosted at [GitHub][repo]
9097
* Report issues/questions/feature requests on [GitHub Issues][issues]
@@ -99,11 +106,11 @@ example:
99106
4. Push to the branch (`git push origin my-new-feature`)
100107
5. Create new Pull Request
101108

102-
## <a name="authors"></a> Authors
109+
## Authors
103110

104111
Created and maintained by [Sean Porter][author] (<portertech@gmail.com>)
105112

106-
## <a name="license"></a> License
113+
## License
107114

108115
Apache 2.0 (see [LICENSE][license])
109116

lib/kitchen/driver/docker.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Docker < Kitchen::Driver::SSHBase
3131
default_config :image, 'base'
3232
default_config :platform, 'ubuntu'
3333
default_config :port, '22'
34+
default_config :memory, nil
3435
default_config :username, 'kitchen'
3536
default_config :password, 'kitchen'
3637
default_config :require_chef_omnibus, true
@@ -124,6 +125,7 @@ def run_container(state)
124125
Array(config[:forward]).each do |port|
125126
cmd << " -p #{port}"
126127
end
128+
cmd << " -m #{config[:memory]}" if config[:memory]
127129
cmd << " #{image_id} /usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no"
128130
output = run_command(cmd)
129131
parse_container_id(output)

0 commit comments

Comments
 (0)