Docker-compose and Xvfb incompatibility?

2.1k Views Asked by At

Since I installed Capybara-webkit, I can't launch my specs with docker compose. The next command stays on hold:

$ docker-compose run web xvfb-run -a bundle exec rspec

I thought I have a problem with Capybara-webkit, so I created a SO question and an issue on the repo, but it seems it's more a pb of interaction between docker-compose and xvfb.

If I do first

$ docker-compose run web bash

then

$ xvfb-run -a bundle exec rspec spec

it works fine. I have no clue.

Edit 31/08/17

As requested, here is the docker-compose file:

version: '2'

services:

  db:
    image: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=XXXXX
    volumes:
      - mysql-data:/var/lib/mysql

  redis:
    image: redis
    ports:
      - "6379:6379"
    volumes:
      - redis:/data

  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/app_dir
      - app-gems:/usr/local/bundle
    ports:
      - "3000:3000"
    depends_on:
      - db
      - redis

volumes:
  mysql-data:
    driver: local
  redis:
    driver: local
  app-gems:
    driver: local

And the Dockerfile:

FROM ruby:2.4.1

RUN apt-get update -qq && apt-get install -y \
  build-essential \
  libpq-dev \
  nodejs \
  xvfb \
  qt5-default \
  libqt5webkit5-dev \
  gstreamer1.0-plugins-base \
  gstreamer1.0-tools \
  gstreamer1.0-x

RUN mkdir /app_dir
WORKDIR /app_dir

ADD Gemfile* /app_dir/

RUN bundle install

COPY . .
2

There are 2 best solutions below

0
On

Posting comments as answer since I need formatting

Can you try changing below

command: bundle exec rails s -p 3000 -b '0.0.0.0'

to

entrypoint: xvfb-run -a bundle exec rspec

and try docker-compose up

Also if that doesn't work then try adding tty: true to the service

0
On

In docker-compose.yml

command: ./start.sh

And in start.sh file

#!/bin/bash
xvfb-run "run whatever"