Portainer; Install tutor inside a container

Hello everybody,
I have been trying to spin tutor directly inside a container on a Portainer platform
I encounter some issues like:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

I do not want to have a docker-in-docker as tutor is trying to spin up a docker as well.

  1. Has anyone able to setup tutor directly inside a container? Please help.
  2. Should I look into doing openedx (production/devstack) ways?

Any pointer or direction, suggestion will be highly appreciated. Many thanks!
Hear from you soon.

God blesses!!!

Regards
Sanyaade

Hello Sanyaade,

Please consider creating a python virtual environment inside the tutor directory using the following command:
python3 -m venv venv
after that activate the virtual environment using this command:
source venv/bin/activate
then you should be able to install tutor inside that environment using pip install -e . and completing your tutor installation.

Best regards,
Fuad Bader

Hello @FuadBader,

Many thanks for your quick reply and for the giving directions and what I need to do.
I will follow your instructions and steps and get back to you.

Once again, many thanks!
Much appreciated.

God blesses!!!

Regards

Hi @FuadBader,

Just give a go, but the installation fails again.
Same issue and problem trying to execute a docker-compose (alas in a docker container) file inside a docker container.

The error:

==================================================
        Interactive platform configuration
==================================================
Are you configuring a production platform? Type 'n' if you are just testing Tutor on your local computer [Y/n] y
Your website domain name for students (LMS) [openedx.educateiot.com] 
Your website domain name for teachers (CMS) [studio.educateiot.com] 
Your platform name/title [Awon Omo Yoruba] 
Your public contact email address [contact@openedx.educateiot.com] 
The default language code for the platform [en] 
Activate SSL/TLS certificates for HTTPS access? Important note: this will NOT work in a development environment. [Y/n] n
Configuration saved to /root/.local/share/tutor/config.yml
Unknown error rendering template dev/docker-compose.yml
Traceback (most recent call last):
  File "/venv/bin/tutor", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/tutor/tutor/commands/cli.py", line 27, in main
    cli()  # pylint: disable=no-value-for-parameter
    ^^^^^
  File "/venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tutor/tutor/commands/compose.py", line 99, in launch
    interactive_configuration(context, not non_interactive, run_for_prod=run_for_prod)
  File "/tutor/tutor/commands/compose.py", line 198, in interactive_configuration
    tutor_env.save(context.obj.root, config)
  File "/tutor/tutor/env.py", line 335, in save
    save_all_from(src, os.path.join(root_env, dst), config)
  File "/tutor/tutor/env.py", line 353, in save_all_from
    renderer.render_all_to(dst, prefix.replace(os.sep, "/"))
  File "/tutor/tutor/env.py", line 220, in render_all_to
    rendered = self.render_template(template_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tutor/tutor/env.py", line 207, in render_template
    return self.__render(template)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/tutor/tutor/env.py", line 226, in __render
    return template.render(**self.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/venv/lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/tutor/tutor/templates/dev/docker-compose.yml", line 47, in top-level template code
    {% if RUN_ELASTICSEARCH and is_docker_rootless() %}
  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tutor/tutor/utils.py", line 184, in is_docker_rootless
    results = subprocess.run(["docker", "info"], capture_output=True, check=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'docker'
(venv) root@0fe5d2d3524c:/# 

Hoops, screenshot images restriction. This forum wont allow me to upload the error images

I am looking at the repository again to see if I could late the main-installer scripts for study and adaptation

God blesses!!!

Regards

Hello @sanyaade-teachings,
Could you please provide more context on what docker image/container you are using to deploy Tutor?

Best regards

Hi @FuadBader

Good day to you, many thanks for your continuous support.
I am try deploy a tutor inside an ubuntu 22.04 container.
I have a portainer ce (https://www.portainer.io/ ) platform running a server. I could create an ubuntu container and ssh into it to deploy tutor. I think the issue as I believe is that tutor installer scripts is configure to spin up its own container whereas in my case, I already have a container running and I am inside it.

If I could locate tutor main installer script then, may be I could override those section to have a non-dockerised tutor installation.

Many thanks for your support. Much appreciated!

Hear from you soon.

God blesses!!!

Regards

I have the same problem. I am also running on Ubuntu 22.04.

I used the local deployment Tutor install instructions. I installed Docker Compose using the standalone install instructions. The install of Tutor works fine after activating a VENV. But the launch fails for me too.

I have replaced my domain with sample below.

k5blearn@learning:~/tutor$ source venv/bin/activate
(venv) k5blearn@learning:~/tutor$ tutor local launch
:warning: Failed to enable plugin ‘indigo’: plugin ‘indigo’ is not installed.
:warning: Failed to enable plugin ‘mfe’: plugin ‘mfe’ is not installed.

    Interactive platform configuration

==================================================
Are you configuring a production platform? Type ‘n’ if you are just testing Tutor on your local computer [Y/n] y
Your website domain name for students (LMS) [learn.sample.com]
Your website domain name for teachers (CMS) [studio.learn.sample.com]
Your platform name/title [Sample University]
Your public contact email address [learn@sample.com]
The default language code for the platform [en]
Activate SSL/TLS certificates for HTTPS access? Important note: this will NOT work in a development environment. [Y/n] y
Configuration saved to /home/k5blearn/.local/share/tutor/config.yml
Unknown error rendering template dev/docker-compose.yml
Traceback (most recent call last):
File “/home/k5blearn/tutor/venv/bin/tutor”, line 8, in
sys.exit(main())
^^^^^^
File “/home/k5blearn/tutor/tutor/commands/cli.py”, line 27, in main
cli() # pylint: disable=no-value-for-parameter
^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/core.py”, line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/core.py”, line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/core.py”, line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/click/decorators.py”, line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/tutor/commands/compose.py”, line 99, in launch
interactive_configuration(context, not non_interactive, run_for_prod=run_for_prod)
File “/home/k5blearn/tutor/tutor/commands/compose.py”, line 204, in interactive_configuration
tutor_env.save(context.obj.root, config)
File “/home/k5blearn/tutor/tutor/env.py”, line 335, in save
save_all_from(src, os.path.join(root_env, dst), config)
File “/home/k5blearn/tutor/tutor/env.py”, line 353, in save_all_from
renderer.render_all_to(dst, prefix.replace(os.sep, “/”))
File “/home/k5blearn/tutor/tutor/env.py”, line 220, in render_all_to
rendered = self.render_template(template_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/tutor/env.py”, line 207, in render_template
return self.__render(template)
^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/tutor/env.py”, line 226, in __render
return template.render(**self.config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/jinja2/environment.py”, line 1304, in render
self.environment.handle_exception()
File “/home/k5blearn/tutor/venv/lib/python3.12/site-packages/jinja2/environment.py”, line 939, in handle_exception
raise rewrite_traceback_stack(source=source)
File “/home/k5blearn/tutor/tutor/templates/dev/docker-compose.yml”, line 47, in top-level template code
{% if RUN_ELASTICSEARCH and is_docker_rootless() %}
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/k5blearn/tutor/tutor/utils.py”, line 184, in is_docker_rootless
results = subprocess.run([“docker”, “info”], capture_output=True, check=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/subprocess.py”, line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/subprocess.py”, line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.12/subprocess.py”, line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘docker’

Any suggestions?