Circle 2.0: pre-built images can't start a .service

container-image

#1

Using the pre-built Debian 8 images. Starting a .service

sudo systemctl start rethinkdb

breaks with:

Failed to get D-Bus connection: Unknown error -1

Currently using an old-style SysVinit bash script as a workaround. But I’d rather not.

config.yml is below

# See https://circleci.com/docs/2.0/configuration-reference (badly written)
# And https://circleci.com/docs/2.0/configuration-reference/#full-example (better)
version: 2
jobs:
  build:
    docker:
      # Circle does not currently have a node 8 image
      # https://circleci.com/docs/2.0/circleci-images/#nodejs
      - image: circleci/node:latest

    # Note this needs a trailing slash or Circle will fail.
    # Cannot be '~/' - see https://discuss.circleci.com/t/directory-tmp-you-are-trying-to-checkout-to-is-not-empty-and-not-git-repository/11370
    working_directory: '~/myapp'
    branches:
      only:
        - master # list of branches to build

    steps:
      - checkout

      # Debian doesn't consider LSB essential. Sigh.
      - run: sudo apt-get install lsb-release

      # Remove when https://github.com/npm/npm/issues/16883 is fixed
      - run: sudo npm install -g npm@4.6.1

      - run: sudo npm install -g mocha

      # From https://rethinkdb.com/docs/install/debian/
      - run: echo "deb http://download.rethinkdb.com/apt `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
      - run: wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
      - run: sudo apt-get update
      - run: sudo apt-get install rethinkdb

      # From https://www.rethinkdb.com/docs/start-on-startup/
      # (systemctl currently fails with 'Failed to get D-Bus connection: Unknown error -1')
      - run: sudo cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
      - run: sudo /etc/init.d/rethinkdb start

      - run: node --version
      - run: npm --version
      - run: mocha --version
      - run: rethinkdb --version
      - run: pwd

      # Needed to restore local modules deleted by npm 5 (which is run to get npm v4 - sigh....)
      - run: git checkout -- ./node_modules

      - run: npm install
      - run: ./run-tests.sh

#2

I am not sure why its not starting but is there a reason why you are installing it in the same container rather than adding rethinkdb as a separate docker service?

https://hub.docker.com/_/rethinkdb/

i.e.

  build:
    docker:
      # Circle does not currently have a node 8 image
      # https://circleci.com/docs/2.0/circleci-images/#nodejs
      - image: circleci/node:latest
      - image: rethinkdb:$VERSION

This is our recommended way for running all additional services.


#3