Skip to content

snewhouse/switch-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

switch-os

Seamlessly switch between host OS and guest OS using Docker 🐳 . Inspired by: oswitch

VERSION=17.07.v0.2
AUTHOR=Stephen Newhouse stephen.j.newhouse@gmail.com

DOI

Requirements

Get it

git clone https://github.com/snewhouse/switch-os.git

Features

  • sets Docker UID ENV to HOST $UID
  • sets Docker USER ENV to HOST $USER
  • mounts HOST user $HOME to Docker Volume /home/$USER
  • sets Docker WORKDIR to /home/$USER
  • Option to remove container on exit

Usage

 Usage:
        switch-os.sh <REPOSITORY:TAG> <true|false>
        

        <true|false>: The second flag sets the option to remove the
        container on exit. Set this to false if you make changes to the 
        running image and wish to commit the changes for future use.
        
  List Images:
  
        switch-os.sh list      

Current Guest/Docker OS's:

  • ubuntu:16.04
  • yeban/biolinux:8

To use any other image on your machine, just provide REPOSITORY:TAG If image is not already on your system, Docker will pull it from Docker Hub, if its available.

The docker run command

# run selected Docker OS
CMD="docker run --rm=${2} \
    --name ${NAME}_$(date +%y%m%d%M) \
    -v ${HOME}:/home/${USER} \
    -e USER=${USER} \
    -e USERID=${UID} \
    -w=/home/${USER} \
    -i -t ${DOCKER_OS} bash"

Example: Run Ubuntu:16.04

switch-os.sh ubuntu true

example output to screen (on my local macbook-pro):

switch-os:17.07.v0.1
------------------------
Running:
Setting Container UID: 501
Setting Container USER: sjnewhouse
Mounting HOST Volume /Users/sjnewhouse to Container Volume: /home/sjnewhouse
Setting Container WORKDIR: /home/sjnewhouse
Remove Container on Exit (--rm=true|false): true
docker run --rm=true     --name ubuntu_16.04_17070804     -v /Users/sjnewhouse:/home/sjnewhouse     -e USER=sjnewhouse     -e USERID=501     -w=/home/sjnewhouse     -i -t  bash

Cite As

Stephen J Newhouse. (2017, July 8). snewhouse/switch-os: 17.07.v0.2. Zenodo. http://doi.org/10.5281/zenodo.824419

@misc{stephen_j_newhouse_2017_824419,
  author       = {Stephen J Newhouse},
  title        = {snewhouse/switch-os: 17.07.v0.2},
  month        = jul,
  year         = 2017,
  doi          = {10.5281/zenodo.824419},
  url          = {https://doi.org/10.5281/zenodo.824419}
}

Core Contributors

Contributors

Full list at Contributors


Development funded as part of:
NIHR Maudsley Biomedical Research Centre (BRC), King's College London and the
Farr Institute of Health Informatics Research, UCL Institute of Health Informatics, University College London
PHI Data Lab:
Institute of Psychiatry, Psychology & Neuroscience,King's College London.