Using gitlab ci with docker compose leaves me with container generated folders gitlab can't remove

I’m trying to set up gitlab ci using the method documented here and testing a rails 4 app with it.

The problem I’m having is that the test will run once and build the image and containers, but when I try to run the test again it will fail with:

  • persist and share data from docker mongo container (with docker)
  • Can I update the hostname of a Docker Node?
  • Dockerhub automated build: BitBucket repository with private submodules
  • how to pass command line arguments to a python script running in docker
  • Running python web app from docker
  • Installing imagemagick in docker container
  • gitlab-ci-multi-runner 1.1.3 (a470667)
    Using Shell executor...
    Running on ubuntu-lon1-01...
    Fetching changes...
    warning: failed to remove tmp/miniprofiler
    
    ERROR: Build failed: exit status 1
    

    I think this is because the tmp folder is generated when you run the app a first time and is owned by root in the container.

    This is the gitlab.ci.yml I’m currently using but I’ve tried lots of different versions all with the same result:

    before_script:
      - docker info
    
    build_image:
      stage: test
        script:
        -  docker-compose build
        -  docker-compose run web rake db:create RAILS_ENV=test
        -  docker-compose run web bin/rake db:migrate RAILS_ENV=test
        -  docker-compose up -d
        -  docker-compose run web bundle exec rspec
        -  docker-compose stop
    

    I thought I may be able to delete the folder using the after_script but that doesn’t work with the shell setup.

    I’m not sure how to handle this. I think I need to either delete it on exit or change the permissions so it can be deleted.

    This is my Dockerfile:

    FROM ruby:2.3.1
    
    RUN apt-get update -qq && apt-get install -y build-essential \
        && apt-get install -y apt-utils \
        && apt-get install -y libqt4-webkit libqt4-dev xvfb \
        && apt-get install -y wget \
        && apt-get install -y libpq-dev \
        && apt-get install -y postgresql-contrib \
        && apt-get install -y libxml2-dev libxslt1-dev \
        && apt-get install -y imagemagick libmagickcore-dev libmagickwand-dev \
        && apt-get install -y nodejs
    
    RUN gem install foreman
    
    WORKDIR /tmp
    COPY Gemfile Gemfile
    COPY Gemfile.lock Gemfile.lock
    RUN bundle install
    
    RUN mkdir /app
    WORKDIR /app
    COPY . /app/
    

    And my docker-compose:

    db:
      image: postgres:9.4
      ports:
        - "5432"
    web:
      build: .
      command: foreman start -f Procfile.dev
      volumes:
        - .:/app
      stdin_open: true
      ports:
        - "3000:3000"
      links:
        - db
    

    Googling I can’t seem to find anyone that’s having the same issue so I’m assuming I’m doing something wrong.

    Thanks.

  • docker disk space grows faster than container's
  • Howto change (syslog) log target in Postfix (3) for docker usage
  • How to move docker installation to another machine?
  • How does Hotspot JVM determine exactly the current timezone on Linux(Centos)?
  • Can I set Neo4j on Docker to import CSV file on the first run, not after that?
  • How to specify docker image path on command line without editing configuration setting?
  • One Solution collect form web for “Using gitlab ci with docker compose leaves me with container generated folders gitlab can't remove”

    I thought I may be able to delete the folder using the after_script but that doesn’t work with the shell setup.

    I had the same issue and solved it by adding this to .gitlab.ci.yml

    after_script:
      - docker-compose run web rm -rf tmp/
    

    (Using shell runner with gitlab-ci-multi-runner 1.7.1)

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.