Run command on host when using docker

docker

#1

Hi

I’m using docker executor with CircleCI 2.0.
I need to run a command on the host machine, but don’t find a way to do it.
https://circleci.com/docs/2.0/configuration-reference/#steps

The command I want to run on the host machine is as follows

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

My content of my CircleCI config.yml is as follows:

# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.4.1-node-browsers
        environment:
          RAILS_ENV: test
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4
      - image: circleci/mysql:5.7

    working_directory: ~/repo

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "Gemfile.lock" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: install dependencies
          command: |
            bundle install --jobs=4 --retry=3 --path vendor/bundle

      - save_cache:
          paths:
            - ./venv
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # Database setup
      - run: bin/rails db:migrate:reset

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            bin/rspec --format RspecJunitFormatter \
                      --out /tmp/test-results/rspec.xml

      # collect reports
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results

So, my question is, how can I run a command on the host when using docker executor.
Thank you.


#2

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.