Saving a Python file in a docker container

Hello there,
I am trying to save an extensions.py file to my jetson so that when the docker runs, it imports pyserial and when I saved the file (im using vim) and what is happening is that when i closed down the docker container and reopened it, I found out that it did not acctualy save the file.

I realized that it was in a docker container (which only saves on the session it is on and destroys anything after the session closes) and I remembered that the extensions.py file was IN the docker which meant that it would not save locally to the Jetson.

My question is how would I save that Python file to the Jetson’s local files because that extensions file looks to be an important file and it has to stay in this directory: /usr/local/lib/python3.6/dist-packages/notebook

I was wondering if I could put it into the “data” directory where I have files that are saved localy are because on Jupyter labs, I have the directory “data” as the directory that runs when you run the docker command. here is a picture of the data directory with a Python file I got saved localy with which runs when i load the docker:

image

Here is the edited Python file with pyserial:

"""Utilities for installing extensions"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import os
import pyserial
from tornado.log import LogFormatter
from traitlets import Bool, Any
from jupyter_core.application import JupyterApp
from jupyter_core.paths import (
    jupyter_config_dir, ENV_CONFIG_PATH, SYSTEM_CONFIG_PATH
)
from ._version import __version__

class ArgumentConflict(ValueError):
    pass

_base_flags = {}
_base_flags.update(JupyterApp.flags)
_base_flags.pop("y", None)
_base_flags.pop("generate-config", None)
_base_flags.update({
    "user" : ({
        "BaseExtensionApp" : {
            "user" : True,
        }}, "Apply the operation only for the given user"
    ),
    "system" : ({
        "BaseExtensionApp" : {
            "user" : False,
            "sys_prefix": False,
        }}, "Apply the operation system-wide"
    ),
    "sys-prefix" : ({
        "BaseExtensionApp" : {
            "sys_prefix" : True,
        }}, "Use sys.prefix as the prefix for installing nbextensions (for environments, packaging)"
    ),
    "py" : ({
        "BaseExtensionApp" : {
            "python" : True,
        }}, "Install from a Python package"
    )
})
_base_flags['python'] = _base_flags['py']

_base_aliases = {}
_base_aliases.update(JupyterApp.aliases)


class BaseExtensionApp(JupyterApp):
    """Base nbextension installer app"""
    _log_formatter_cls = LogFormatter
    flags = _base_flags
    aliases = _base_aliases
    version = __version__

    user = Bool(False, config=True, help="Whether to do a user install")
    sys_prefix = Bool(False, config=True, help="Use the sys.prefix as the prefix")
    python = Bool(False, config=True, help="Install from a Python package")

"extensions.py" 104L, 3322C    

Please tell me if I have to include any more details. Thanks!

324Hz
win21H2
he/him

Hi,

You can run the container with the -v flag to mount a folder for saving the files.
Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.