Hi Team,
I am trying to upgrade the couchbase version from enterprise-6.0.3 to 6.6.1 version, but the problem when I am trying to build the image it says python not found, the same thing works fine in 6.0.3 version.
below is my dockerfile.
FROM couchbase:enterprise-6.6.1
WORKDIR /usr/scripts/
COPY py-scripts/* ./
RUN curl -O https://bootstrap.pypa.io/get-pip.py
&& python get-pip.py
&& pip install awscli
&& pip install --upgrade rsa
&& pip install requests \
Please suggest me why it says python not found and how can I resolve the same.
Python is installed, but bundled as part of Couchbase, not the base operating system (as we’d have little control over versioning otherwise).
Run docker inspect image couchbase/server:6.6.1 and you should see something similar to:
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/couchbase/bin:/opt/couchbase/bin/tools:/opt/couchbase/bin/install"
],
tl;dr use an absolute path or whatever. Note, one thing that caught me out before is even though it’s called python and pip, it’s actually python 3, so be aware of this.
Also I’m by no means an expert!
Just had a deeper inspection myself. While that may have been true of earlier versions, on 6.6.0 I get:
$ docker run --rm -ti couchbase/server:6.6.0 bash
root@98fe1e09ec21:/# which python
root@98fe1e09ec21:/# which python3
root@98fe1e09ec21:/#
However…
root@98fe1e09ec21:/# find /opt/couchbase/ -name pip
/opt/couchbase/lib/python/runtime/lib/python3.7/site-packages/pip
/opt/couchbase/lib/python/runtime/bin/pip
So it may have been removed from the PATH, but it is still there. Now whether you should setup the PATH to point to the Couchbase version, or just install the OS’s version I’ll leave to an expert, but that should help you out in the short term.
Hi @simon.murray
Thanks the for reply. sorry I didn’t get it properly
This is my docker file, I want to install python 3, when I tried with RUN apt-get install -y python3.6 it says python3.6 not found. can you please suggest how can I install python3x version.
When I do RUN apt-get install -y python its installing python 2.7 version.
FROM couchbase:enterprise-6.6.1
WORKDIR /usr/scripts/
RUN apt-get update
RUN apt-get install -y python3.6
You get the latest python (3.8 or maybe 3.9) with apt-get install python3
. If you really need python3.6, you’d need to add the deadsnakes ppa to get it – something like :
add-apt-repository ppa:deadsnakes/ppa
apt update
Hi @simon.murray
If I append the path /opt/couchbase/lib/python for python command as given below, it says permission denied.
RUN curl -O https://bootstrap.pypa.io/get-pip.py
&& /opt/couchbase/lib/python get-pip.py
I tried if the python command get recognize from /opt/couchbase/lib/python path but it is says python not found.
root@106e8a879e14:/# cd /opt/couchbase/lib/python
root@106e8a879e14:/opt/couchbase/lib/python# python --version
bash: python: command not found
root@106e8a879e14:/opt/couchbase/lib/python# cd …
root@106e8a879e14:/opt/couchbase/lib# python --version
bash: python: command not found
root@106e8a879e14:/opt/couchbase/lib# cd …
root@106e8a879e14:/opt/couchbase# python --version
bash: python: command not found
root@106e8a879e14:/opt/couchbase# cd …
root@106e8a879e14:/opt# python --version
bash: python: command not found
root@106e8a879e14:/opt# cd …
root@106e8a879e14:/# python --version
bash: python: command not found
I do not want to run below commands to install python as I do not want to run apt-get update and without that apt-get install will not work.
RUN apt-get update
RUN apt-get install -y python3.6
You are not using the right directory and also not specifying to run python from the current directory so it will not find it - this is a PATH issue rather than anything else. You need to do the following to get this to work:
root@aebe3751b290:~# /opt/couchbase/lib/python/runtime/bin/python3.7 --version
Python 3.7.3
root@aebe3751b290:/opt/couchbase/lib/python/runtime/bin# cd /opt/couchbase/lib/python/runtime/bin
root@aebe3751b290:/opt/couchbase/lib/python/runtime/bin# ./python3.7 --version
Python 3.7.3
root@aebe3751b290:/opt/couchbase/lib/python/runtime/bin# python3.7 --version
bash: python3.7: command not found
Notice the use of ./
to indicate to run the command in the current directory and not search the PATH. You should be able to use the python
and pip
commands at the location specified to carry out what you need.
As @davidkelly indicates above you can get the latest python by installing it, however if you want a specific version then you have to add another repository which requires apt update
to be run.
It is best practice as well to always run apt update
as part of the same RUN
statement: Overview of best practices for writing Dockerfiles | Docker Docs
You can combine your commands into a single RUN
command ideally with the additional commands to remove the cache afterwards.