Hi
I put the following code on dockerfile :
RUN git clone --depth=1 GitHub - anchore/anchore-cli: Simple command-line client to the Anchore Engine service &&
cd anchore-cli &&
python3 -m pip install --user --upgrade anchorecli
but it showed me the error :ERROR: failed to solve: process “/bin/sh -c git clone --depth=1 GitHub - anchore/anchore-cli: Simple command-line client to the Anchore Engine service && cd anchore-cli && python3 -m pip install --user --upgrade anchorecli” did not complete successfully: exit code: 1 , Why?
Hello,
The error you’re encountering in your Dockerfile likely stems from a combination of factors:
Incorrect Git URL format: There seems to be an extra space after GitHub and before the -. The correct format should be:
git clone --depth=1
User permissions for pip: Using --user with pip install might cause permission issues within the Docker container.
Here’s a revised version of your Dockerfile code that addresses these issues:
Dockerfile
RUN git clone --depth=1
cd anchore-cli &&
python3 -m pip install anchorecli
Use code with caution.
content_copy
Explanation of the changes:
The Git URL is corrected to the proper format Official Website
We removed the --user flag from pip install. By default, pip will install packages globally within the container’s environment.
Additional Tips:
You can specify a specific Python version using pythonX.Y instead of just python3 if needed.
Consider using a multi-stage build to keep the final image size smaller. In this case, you could have a stage to install the anchore-cli and then copy it to a minimal image.
By making these adjustments, you should be able to successfully install anchorecli within your Docker container.