diff --git a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample index c8624ca72ec..f2a73402e81 100644 --- a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample +++ b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample @@ -1,5 +1,4 @@ [main] - # Following options are ignored if using the Galaxy dynamic proxy but # are useful if mapping a range of ports for environment consumption. #apache_urls = False @@ -7,32 +6,39 @@ #ssl = False [docker] - -# Command to execute docker. For example `sudo docker` or `docker-lxc`. -command = docker +# Command to launch docker container. For example `sudo docker` or `docker-lxc`. +# If you need to use a command like `sg` you can do that here, just be sure to +# wrap all of the docker portion in single quotes. E.g. `sg 'docker' 'docker {docker_args}'` +# +# It is recommended that you use command_inject if you need to inject +# additional parameters. This command string is re-used for a `docker inspect` +# command and will likely cause errors if it is extensively modified, past the +# usual group/sudo changes. +#command = docker {docker_args} # The docker image name that should be started. image = bgruening/docker-ipython-notebook:dev # Additional arguments that are passed to the `docker run` command. -command_inject = --sig-proxy=true -e DEBUG=false - -# Command to wrap around the full docker command. -# For example, `sg 'docker' '{cmd}'` where {cmd} will be replaced by the full -# docker command. Make sure to surround the {cmd} with single quotes('). -# Default: empty -#command_wrapper = +#command_inject = --sig-proxy=true -e DEBUG=false # URL to access the Galaxy API with from the spawn Docker containter, if empty # this falls back to galaxy.ini's galaxy_infrastructure_url and finally to the # Docker host of the spawned container if that is also not set. -#galaxy_url = +#galaxy_url = # The Docker hostname. It can be useful to run the Docker daemon on a different # host than Galaxy. #docker_hostname = localhost # Try to set the tempdirectory to world execute - this can fix the issue -# where 'sudo docker' is not able to mount the folder otherwise. +# where 'sudo docker' is not able to mount the folder otherwise. # "finalize namespace chdir to /import permission denied" -wx_tempdir = False \ No newline at end of file +#wx_tempdir = False + +# Overwride the IE tempdirectory. This can be useful if you regular tempdir is +# located on an NFS share, which does not work well as Docker volume. In this case +# you can have a shared sshfs share which you can use as temporary directory to +# share data between the IE and Galaxy. +#docker_galaxy_temp_dir = None + diff --git a/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample b/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample index ed0b64ff7ce..d678c8752dc 100644 --- a/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample +++ b/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample @@ -1,19 +1,44 @@ [main] -# This cannot be changed +# This CANNOT be changed. Eventually will be deprecated password_auth = True -# Other -apache_urls = False -ssl = False +# Following options are ignored if using the Galaxy dynamic proxy but +# are useful if mapping a range of ports for environment consumption. +#apache_urls = False +#ssl = False [docker] -command = docker +# Command to launch docker container. For example `sudo docker` or `docker-lxc`. +# If you need to use a command like `sg` you can do that here, just be sure to +# wrap all of the docker portion in single quotes. E.g. `sg 'docker' 'docker {docker_args}'` +# +# It is recommended that you use command_inject if you need to inject +# additional parameters. This command string is re-used for a `docker inspect` +# command and will likely cause errors if it is extensively modified, past the +# usual group/sudo changes. +#command = docker {docker_args} + +# The docker image name that should be started. image = erasche/docker-rstudio-notebook:dev -# Additional arguments that are passed to the `docker run` command. `-u` -# settings are completely ignored. -command_inject = --sig-proxy=true -e DEBUG=false +# Additional arguments that are passed to the `docker run` command. +#command_inject = --sig-proxy=true -e DEBUG=false -# URL to access the Galaxy API with from the spawned Docker container, if empty +# URL to access the Galaxy API with from the spawn Docker containter, if empty # this falls back to galaxy.ini's galaxy_infrastructure_url and finally to the -# Docker host of the spawned container, if that is also not set. -#galaxy_url= +# Docker host of the spawned container if that is also not set. +#galaxy_url = + +# The Docker hostname. It can be useful to run the Docker daemon on a different +# host than Galaxy. +#docker_hostname = localhost + +# Try to set the tempdirectory to world execute - this can fix the issue +# where 'sudo docker' is not able to mount the folder otherwise. +# "finalize namespace chdir to /import permission denied" +#wx_tempdir = False + +# Overwride the IE tempdirectory. This can be useful if you regular tempdir is +# located on an NFS share, which does not work well as Docker volume. In this case +# you can have a shared sshfs share which you can use as temporary directory to +# share data between the IE and Galaxy. +#docker_galaxy_temp_dir = None diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index 297ffef099b..ce850f2d850 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -51,7 +51,9 @@ class InteractiveEnviornmentRequest(object): self.notebook_pw_salt = self.generate_password(length=12) self.notebook_pw = self.generate_password(length=24) - self.temp_dir = os.path.abspath( tempfile.mkdtemp() ) + ie_parent_temp_dir = self.attr.viz_config.get("docker", "docker_galaxy_temp_dir") or None + self.temp_dir = os.path.abspath( tempfile.mkdtemp( dir=ie_parent_temp_dir ) ) + if self.attr.viz_config.getboolean("docker", "wx_tempdir"): # Ensure permissions are set try: @@ -65,10 +67,13 @@ class InteractiveEnviornmentRequest(object): # will need to be recorded here. The ConfigParser doesn't provide a # .get() that will ignore missing sections, so we must make use of # their defaults dictionary instead. - default_dict['command_inject'] = '--sig-proxy=true' - default_dict['docker_hostname'] = 'localhost' - default_dict['wx_tempdir'] = 'False' - default_dict['command_wrapper'] = '' + default_dict = { + 'command': 'docker {docker_args}', + 'command_inject': '--sig-proxy=true -e DEBUG=false', + 'docker_hostname': 'localhost', + 'wx_tempdir': 'False', + 'docker_galaxy_temp_dir': None + } viz_config = ConfigParser.SafeConfigParser(default_dict) conf_path = os.path.join( self.attr.our_config_dir, self.attr.viz_id + ".ini" ) if not os.path.exists( conf_path ): @@ -182,18 +187,24 @@ class InteractiveEnviornmentRequest(object): conf.update(env_override) env_str = ' '.join(['-e "%s=%s"' % (key.upper(), item) for key, item in conf.items()]) volume_str = ' '.join(['-v "%s"' % volume for volume in volumes]) - cmd = '%s run %s -d %s -p %s:%s -v "%s:/import/" %s %s' % \ - (self.attr.viz_config.get("docker", "command"), - env_str, - self.attr.viz_config.get("docker", "command_inject"), - self.attr.PORT, self.attr.docker_port, - temp_dir, - volume_str, - self.attr.viz_config.get("docker", "image")) - cmd_wrapper = self.attr.viz_config.get("docker", "command_wrapper") - if cmd_wrapper != '' and '{cmd}' in cmd_wrapper: - cmd = cmd_wrapper.format( cmd=cmd ) - return cmd + # This is the basic docker command such as "sudo -u docker docker {docker_args}" + # or just "docker {docker_args}" + command = self.attr.viz_config.get("docker", "command") + # Then we format in the entire docker command in place of + # {docker_args}, so as to let the admin not worry about which args are + # getting passed + command = command.format(docker_args='run {command_inject} {environment} -d -p {port_ext}:{port_int} -v "{temp_dir}:/import/" {volume_str} {image}') + # Once that's available, we format again with all of our arguments + command = command.format( + command_inject=self.attr.viz_config.get("docker", "command_inject"), + environment=env_str, + port_ext=self.attr.PORT, + port_int=self.attr.docker_port, + temp_dir=temp_dir, + volume_str=volume_str, + image=self.attr.viz_config.get("docker", "image") + ) + return command def launch(self, raw_cmd=None, env_override={}, volumes=[]): if raw_cmd is None: