直接在docker compose 文件的command 中指定以下参数就可以启用远程访问
serviceName:
image: imageName:latest
command:
- /bin/bash
- -c
- |
jupyter lab --allow-root --no-browser --notebook-dir=/root/stable-baselines --ip "*" --ServerApp.allow_remote_access=True
备注:
0)| 表示一行一条命令,采用| 你可以附加多条命令。
1)--ip 是监听所有IP,本地的localhost 和其它IP
2) --ServerApp.allow_remote_access =True ,启用远程
3) 实际上,配置文件的全部配置项 都可以通过这方式在命令行参数中直接配置。注意去掉配置文件中的c. 。以下提供了jupyter lab默认配置文件,用以搜索复制到上面的命令行参数使用。
jupyter_lab_config.py:
# Configuration file for lab.
#------------------------------------------------------------------------------
# Application(SingletonConfigurable) configuration
#------------------------------------------------------------------------------
## This is an application.
## The date format used by logging formatters for %(asctime)s
# Default: '%Y-%m-%d %H:%M:%S'
# c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
## The Logging format template
# Default: '[%(name)s]%(highlevel)s %(message)s'
# c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
## Set the log level by value or name.
# Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
# Default: 30
# c.Application.log_level = 30
## Instead of starting the Application, dump configuration to stdout
# Default: False
# c.Application.show_config = False
## Instead of starting the Application, dump configuration to stdout (as JSON)
# Default: False
# c.Application.show_config_json = False
#------------------------------------------------------------------------------
# JupyterApp(Application) configuration
#------------------------------------------------------------------------------
## Base class for Jupyter applications
## Answer yes to any prompts.
# Default: False
# c.JupyterApp.answer_yes = False
## Full path of a config file.
# Default: ''
# c.JupyterApp.config_file = ''
## Specify a config file to load.
# Default: ''
# c.JupyterApp.config_file_name = ''
## Generate default config file.
# Default: False
# c.JupyterApp.generate_config = False
## The date format used by logging formatters for %(asctime)s
# See also: Application.log_datefmt
# c.JupyterApp.log_datefmt = '%Y-%m-%d %H:%M:%S'
## The Logging format template
# See also: Application.log_format
# c.JupyterApp.log_format = '[%(name)s]%(highlevel)s %(message)s'
## Set the log level by value or name.
# See also: Application.log_level
# c.JupyterApp.log_level = 30
## Instead of starting the Application, dump configuration to stdout
# See also: Application.show_config
# c.JupyterApp.show_config = False
## Instead of starting the Application, dump configuration to stdout (as JSON)
# See also: Application.show_config_json
# c.JupyterApp.show_config_json = False
#------------------------------------------------------------------------------
# ExtensionApp(JupyterApp) configuration
#------------------------------------------------------------------------------
## Base class for configurable Jupyter Server Extension Applications.
#
# ExtensionApp subclasses can be initialized two ways:
# 1. Extension is listed as a jpserver_extension, and ServerApp calls
# its load_jupyter_server_extension classmethod. This is the
# classic way of loading a server extension.
# 2. Extension is launched directly by calling its `launch_instance`
# class method. This method can be set as a entry_point in
# the extensions setup.py
## Answer yes to any prompts.
# See also: JupyterApp.answer_yes
# c.ExtensionApp.answer_yes = False
## Full path of a config file.
# See also: JupyterApp.config_file
# c.ExtensionApp.config_file = ''
## Specify a config file to load.
# See also: JupyterApp.config_file_name
# c.ExtensionApp.config_file_name = ''
# Default: ''
# c.ExtensionApp.default_url = ''
## Generate default config file.
# See also: JupyterApp.generate_config
# c.ExtensionApp.generate_config = False
## Handlers appended to the server.
# Default: []
# c.ExtensionApp.handlers = []
## The date format used by logging formatters for %(asctime)s
# See also: Application.log_datefmt
# c.ExtensionApp.log_datefmt = '%Y-%m-%d %H:%M:%S'
## The Logging format template
# See also: Application.log_format
# c.ExtensionApp.log_format = '[%(name)s]%(highlevel)s %(message)s'
## Set the log level by value or name.
# See also: Application.log_level
# c.ExtensionApp.log_level = 30
## Whether to open in a browser after starting.
# The specific browser used is platform dependent and
# determined by the python standard library `webbrowser`
# module, unless it is overridden using the --browser
# (ServerApp.browser) configuration option.
# Default: False
# c.ExtensionApp.open_browser = False
## Settings that will passed to the server.
# Default: {}
# c.ExtensionApp.settings = {}
## Instead of starting the Application, dump configuration to stdout
# See also: Application.show_config
# c.ExtensionApp.show_config = False
## Instead of starting the Application, dump configuration to stdout (as JSON)
# See also: Application.show_config_json
# c.ExtensionApp.show_config_json = False
## paths to search for serving static files.
#
# This allows adding javascript/css to be available from the notebook server machine,
# or overriding individual files in the IPython
# Default: []
# c.ExtensionApp.static_paths = []
## Url where the static assets for the extension are served.
# Default: ''
# c.ExtensionApp.static_url_prefix = ''
## Paths to search for serving jinja templates.
#
# Can be used to override templates from notebook.templates.
# Default: []
# c.ExtensionApp.template_paths = []
#------------------------------------------------------------------------------
# LabServerApp(ExtensionApp) configuration
#------------------------------------------------------------------------------
## A Lab Server Application that runs out-of-the-box
## "A list of comma-separated URIs to get the allowed extensions list
#
# .. versionchanged:: 2.0.0
# `LabServerApp.whitetlist_uris` renamed to `allowed_extensions_uris`
# Default: ''
# c.LabServerApp.allowed_extensions_uris = ''
## Answer yes to any prompts.
# See also: JupyterApp.answer_yes
# c.LabServerApp.answer_yes = False
## The application settings directory.
# Default: ''
# c.LabServerApp.app_settings_dir = ''
## The url path for the application.
# Default: '/lab'
# c.LabServerApp.app_url = '/lab'
## Deprecated, use `LabServerApp.blocked_extensions_uris`
# Default: ''
# c.LabServerApp.blacklist_uris = ''
## A list of comma-separated URIs to get the blocked extensions list
#
# .. versionchanged:: 2.0.0
# `LabServerApp.blacklist_uris` renamed to `blocked_extensions_uris`
# Default: ''
# c.LabServerApp.blocked_extensions_uris = ''
## Whether to cache files on the server. This should be `True` except in dev
# mode.
# Default: True
# c.LabServerApp.cache_files = True
## Full path of a config file.
# See also: JupyterApp.config_file
# c.LabServerApp.config_file = ''
## Specify a config file to load.
# See also: JupyterApp.c