Home > OS >  unable to use jq inside docker container even after installing jq as part of the dockerfile
unable to use jq inside docker container even after installing jq as part of the dockerfile

Time:04-08

I am facing a weird error where I have installed a package within my docker image but when I try to use it, it says package/command not found. Below are the details

Dockerfile: RUN statement

    && pip install awscli \
    && pip install gitpython \
    && pip install pymongo \
    && pip install pytz \
    && pip install boto3 \
    && pip install jq \
    && aws --version \
    && pip list \
    && jq --version

Here is the output log where I am listing the packages installed and trying to check the version of jq package that is installed

Collecting jq
  Downloading jq-1.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (592 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 592.5/592.5 KB 11.6 MB/s eta 0:00:00
Installing collected packages: jq
Successfully installed jq-1.2.2
aws-cli/1.22.90 Python/3.10.4 Linux/5.4.109  botocore/1.24.35
Package          Version
---------------- ---------
awscli           1.22.90
boto3            1.21.35
botocore         1.24.35
certifi          2021.10.8
colorama         0.4.3
distlib          0.3.4
docutils         0.15.2
filelock         3.6.0
gitdb            4.0.9
GitPython        3.1.27
jmespath         1.0.0
jq               1.2.2
pip              22.0.4
pipenv           2022.3.24
platformdirs     2.5.1
pyasn1           0.4.8
pymongo          4.1.0
python-dateutil  2.8.2
pytz             2022.1
PyYAML           5.4.1
rsa              4.7.2
s3transfer       0.5.2
setuptools       58.1.0
six              1.16.0
smmap            5.0.0
urllib3          1.26.9
virtualenv       20.13.4
virtualenv-clone 0.5.7
wheel            0.37.1
/bin/sh: 1: jq: not found

The output of jq --version is: /bin/sh: 1: jq: not found

And I am not sure why! I tried it on my local(without docker) and it worked just fine.

Not sure what I am missing here.

Appreciate your help if you can guide me in the right direction.

CodePudding user response:

pip install jq installs the Python bindings for jq, not the binary itself (source).So, this lets you do something like import jq inside a python script, but does not install a binary that you can call in the terminal.

If you need the terminal command jq, install it as a OS package using the respective package managers. For example, for Debian, Ubuntu or relatives:

sudo apt-get install jq

  • Related