Too many docker containers

Hy There,

I have a favor to ask and tell me guys what am I doing wrong with GitLab CI. Firstly the environment.
WebDevelopement is here, so JavaScript, PHP, CSS, HTML, etc. I have a Gitlab server where I wish to run my docker builds. The goal is to use a webserver docker and inside the docker it sets up a database and the whole website and tests it. All done, everything works like a charm. However after a month the server refuses to build any projects. Turn out on the server I had tonns of docker containers. After I remove them all, the server is back again working.
My question is basically: what should I do?

I though of 2 sollutions

  • Create a sudo crontab to remove the containers every week
  • Can’t I tell GitLab to build the container and after the build have succeeded delete it?

Here is my gitlab-ci.yml file for you, so you can see if I’ve made an error:

stages:

  • test
  • dev
  • prod

variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_DATABASE: homestead

services:

  • mysql:latest

php:5.6:
stage: test
image: bobey/docker-gitlab-ci-runner-php5.6
script:

  • composer self-update
  • composer install --no-scripts
  • php artisan clear-compiled
  • php artisan optimize
  • cp .env.gitlab .env
  • php artisan key:generate
  • composer dump-auto
  • php artisan migrate:refresh --seed
  • echo “Running PHPUnit Tests”
  • php vendor/bin/phpunit --colors --debug

developement:
stage: dev
when: on_success
only:

production:
stage: prod
when: on_success
only:

In the staging and production stages I just wish to use the last command so, to curl a specific php file on the servers. However this simple job takes about 1 minute to complete. Why? How can I reduce the time for it?

Thank you in advance!

Have you tried to compare the local build time for this test and the remote build time? It seems that you are using several containers built from scratch.

for instance, it seems that this part could be quite time consuming

Hey Doo,

I’ve already tested and tried to initiate the same “script” locally but here it is done in about 1, at bigger project in 2 minutes. I don’t think that the server is that slow. Do you have any idea about the last problem maybe, about initiating a simple curl command?