'How to install conan inside docker and use

I am trying to use Conan by installing it in a Docker and using that docker. For the same, I did like included these lines in Dockerfile

RUN apt-get install -y python3-pip
RUN sudo python3 -m pip install conan

And after starting docker container I have these lines in my CMakeFile.txt

conan_cmake_run(
    REQUIRES
    ${CONAN_PACKAGES})

The ${CONAN_PACKAGES} is required to build my project. While running the cmakefile I'm getting this error

-- Conan: Automatic detection of conan settings from cmake
-- Conan: Settings= -s;build_type=Debug;-s;compiler=gcc;-s;compiler.version=8;-s;compiler.libcxx=libstdc++11
-- Conan: checking conan executable
-- Conan: Found program /usr/bin/conan
-- Conan: Version found 
-- Conan executing: /usr/bin/conan install . -s build_type=Debug -s compiler=gcc -s compiler.version=8 -s compiler.libcxx=libstdc++11 -g=cmake
CMake Error at cmake/conan.cmake:402 (message):
  Conan install failed='No such file or directory'
Call Stack (most recent call first):
  cmake/conan.cmake:497 (conan_cmake_install)
  CMakeLists.txt:17 (conan_cmake_run)


-- Configuring incomplete, errors occurred!

Addition of conan_remote is working fine. But after creating the docker container executing these line inside docker fixed the problem

pip install conan
sudo ln -s ~/.local/bin/conan /usr/bin/conan

With my initial understanding of conan, I realized that it is looking for user level installation. But in docker everything is installed as root. Can someone please help to fix this? I'm using this version of conan: https://github.com/conan-io/cmake-conan/tree/release/0.15



Solution 1:[1]

Inside the dockerfile instead of

RUN sudo python3 -m pip install conan

try this:

RUN pip install conan

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dávid Tóth