Command not found error in CircleCI

If you see something like this on CircleCI builds when using two docker images:

/bin/bash: {name_of_command}: command not found

Below is example `config.yml` file that uses `circleci/python:3.6.4` as primary image and `circleci/postgres:9.6.2` as an additional image that will run in a separate container with the DB service being available via port 27017 (or whatever port you want to use) in the primary container.

version: 2.1
orbs:
  slack: circleci/slack@4.0.0

jobs:
  build:
    working_directory: ~/circleci-demo-python-django
    docker:
      - image: circleci/python:3.6.4
        environment:
          PIPENV_VENV_IN_PROJECT: true
          DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
      - image: circleci/postgres:9.6.2
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: circle_test  
    steps:
      - checkout
      - run: postgres -V

 

 

This is because all of your commands will run in the first container that is listed (primary container). This is typically not the database container, which means that the postgres cli is likely not installed in the primary container. The same can happen for mysql and mongo.

In these cases you can install the client using sudo pip install or the relevant package manager for the distro your image is running.

example:

- run: sudo pip install postgressql

More details on Discuss here: https://discuss.circleci.com/t/bin-bash-mongo-command-not-found/16218/6

Was this article helpful?
0 out of 10 found this helpful

Comments

0 comments

Please sign in to leave a comment.