GithubHelp home page GithubHelp logo

rdyro / guest_container_tool Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 70 KB

This basic tool allows you to give others access to your computational resources inside an isolated container, without access to your server or other containers.

Python 100.00%
compute container guest ssh docker

guest_container_tool's Introduction

Persistent Guest Container Tool

This tool allows you to create a persistent guest container on a server: you can create a (docker) container for a temporary user that can be accessed via SSH on a random or selected port.

This basic tool allows you to give others access to your computational resources inside an isolated container, without access to your server or other containers.

Quickstart

On the server

$ python3 guest_container_tool.py --help
$ python3 guest_container_tool.py -u rdyro -k "$(cat ~/.ssh/id_rsa.pub)" -c ubuntu -p 2222
$ ssh -p 2222 rdyro@localhost # you're now in the container

Setup

docker setup

Make sure your user account can use docker without sudo, in the docker group:

$ sudo usermod -aG docker $USER
$ # Log out and log back in or run
$ newgrp docker

Help and usage

usage: guest_container_tool.py [-h] [-u USERNAME] [-p PORT] [-k PUBLIC_KEY_STR]
                               [-c CONTAINER_IMAGE] [-g GPUS] [-n]
                               [-H REVERSE_PROXY_HOST] [--config CONFIG]
                               [--extra-docker-run-args EXTRA_DOCKER_RUN_ARGS]

options:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        username
  -p PORT, --port PORT  port
  -k PUBLIC_KEY_STR, --public-key-str PUBLIC_KEY_STR
                        Public RSA key as a string
  -c CONTAINER_IMAGE, --container-image CONTAINER_IMAGE
                        Container image name (e.g., from docker hub
                        `ubuntu:latest`)
  -g GPUS, --gpus GPUS  Whether and what GPUs to pass to docker
  -n, --dry-run         Dry run, do not run the container.
  -H REVERSE_PROXY_HOST, --reverse-proxy-host REVERSE_PROXY_HOST
                        (Optionally) Host to use for reverse proxy. If
                        complicated, use ~/.ssh/config to set up a host alias.
  --config CONFIG       Path to a JSON config file as an alternative to command
                        line arguments.
  --extra-docker-run-args EXTRA_DOCKER_RUN_ARGS
                        Extra arguments to pass to docker run -- when creating the
                        persistent container.

Using a JSON config file instead

Instead of using the command line arguments, you can also make a simple JSON file that mirrors the command line arguments.

example_config.json:

{
  "username": "rdyro",
  "public_key_str": "ssh-rsa ...",
  "container_name": "ubuntu"
}

guest_container_tool's People

Contributors

rdyro avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.