<p>Although we're deploying to Kubernetes, we've found that <code>docker-compose</code> is a nice way of running tests in CI. Either set the <code>IS_TEST</code> flag in your container or use a separate <code>Dockerfile</code> where tests scripts are wired up. That way you can just run <code>docker-compose build</code> to test, and pull in any dependencies you might need as well.</p>

CC BY-SA 3.0
2017-11-10T22:42:54.547Z
2017-11-11T17:43:33.603Z
2017-11-11T17:43:33.603Z
Trondh
<p>One could use <a href="http://serverspec.org/" rel="nofollow noreferrer">serverspec</a> to test whether a service like nginx is exposing ports, .e.g:</p>

<pre><code>require 'spec_helper'

describe port(80) do
  it { should be_listening }
end

describe port(443) do
  it { should be_listening }
end
</code></pre>

<p>Once the serverspec code has been written one could create a script that starts the nginx, subsequently runs the serverspec and finally destroys the nginx.</p>

CC BY-SA 3.0
2017-10-04T12:41:44.493Z
2017-10-04T12:41:44.493Z
030
<p>In my project i am building about 200 containers I want to check in a  smoke test if the containers are still running after a rebuild in pipeline.</p>

<p>I want to  bring up the container with certain parameters and check if it is responding on ports (service being up), or run simple test inside the container.
Best would be to use docker-compose for starting containers, so that paramateres can easily be configured.</p>

<p>Example for a nginx container</p>

<ol>
<li>run  "nginx -t" inside the container to check if the container still has a valid configuration file</li>
<li>check if nginx  is exposing services on port 80 and 443 </li>
</ol>

<p>Similar for other containers, main topic is checking ports for rest services. After bringing up the container(s), the tests should be run and then the whole thing shoudl be shutdown again.</p>

<p>What is the best tool for doing such a thing automated - and not writing everything manually?</p>

CC BY-SA 3.0
2017-10-01T18:42:29.973Z
I an coding something like that in python now. I prefer the flexibility and since it’s a small tool I like the fact the I am not relying on third party tools support
Rsf
CC BY-SA 3.0
2017-11-11T00:11:35.487Z
side note - are you anticipating any speed assumptions e.g. for many containers, many tests iterations going in real time would require for good planning? (depends on how powerful your test environment is of course)..
Ta Mu
<docker><continuous-integration><testing>
Best tool for Docker Container test automation?
Mandragor
# Best tool for Docker Container test automation?

(Asked by: username_0 on 2017-10-01)

In my project i am building about 200 containers I want to check in a smoke test if the containers are still running after a rebuild in pipeline.

I want to bring up the container with certain parameters and check if it is responding on ports (service being up), or run simple test inside the container.
Best would be to use docker-compose for starting containers, so that paramateres can easily be configured.

Example for a nginx container

1. run "nginx -t" inside the container to check if the container still has a valid configuration file
2. check if nginx is exposing services on port 80 and 443

Similar for other containers, main topic is checking ports for rest services. After bringing up the container(s), the tests should be run and then the whole thing shoudl be shutdown again.

What is the best tool for doing such a thing automated - and not writing everything manually?

**Tags:** docker, continuous-integration, testing

> **Comments:**
> **username_1**: I an coding something like that in python now. I prefer the flexibility and since it’s a small tool I like the fact the I am not relying on third party tools support  
> **username_2**: side note - are you anticipating any speed assumptions e.g. for many containers, many tests iterations going in real time would require for good planning? (depends on how powerful your test environment is of course)..  

---

## 2 answers

### Answer by username_3 on 2017-11-10. Score: 2

Although we're deploying to Kubernetes, we've found that `docker-compose` is a nice way of running tests in CI. Either set the `IS_TEST` flag in your container or use a separate `Dockerfile` where tests scripts are wired up. That way you can just run `docker-compose build` to test, and pull in any dependencies you might need as well.


---

### Answer by username_4 on 2017-10-04. Score: 1

One could use serverspec to test whether a service like nginx is exposing ports, .e.g:
require 'spec_helper'

describe port(80) do
  it { should be_listening }
end

describe port(443) do
  it { should be_listening }
end

Once the serverspec code has been written one could create a script that starts the nginx, subsequently runs the serverspec and finally destroys the nginx.


---

