利用Docker搭建Galaxy

前几天再看新买的《python Web开发实践》时发现一个神奇的工具---Docker,官网介绍是

Docker is the world's leading software containerization platform

我不禁想到生物信息学中有许多软件都要在类unix平台上运行,仅有部分移植到Windows上。所以在要想在Windows上运行这些没有移植的软件,要么需要虚拟出一个Linux系统,要不就是利用Windows10上一个新特性--内置ubuntu系统。

所以由于Docker的特性,就多了一种在windows上运行生物信息软件的方法

安装

运行Docker的第一步就是安装。Docker最在仅能在类unix系统运行,后来移植到Windows平台,不过要在Windows上安装Docker也要满足2个要求:

  • Windows10 64位
  • Hyper V
    不满足的话可以用Docker Toolbox替代。

满足以上条件后只要下载InstallDocker.msi并运行就行了。

然后打开powershell,输入一下指令检查是否安装成功

> docker version
> docker-compose --version
> docker-machine --version

如果以上命令都没有报错则安装完成。此外在命令行直接输入docker就会出现docker的参数说明,具体使用方法见后面的案例。

Usage: docker [OPTIONS] COMMAND [arg...]
       docker [ --help | -v | --version ]

A self-sufficient runtime for containers.

Options:

  --config=%USERPROFILE%\.docker              Location of client config files
  -D, --debug                                 Enable debug mode
  -H, --host=[]                               Daemon socket(s) to connect to
  -h, --help                                  Print usage
  -l, --log-level=info                        Set the logging level
  --tls                                       Use TLS; implied by --tlsverify
  --tlscacert=%USERPROFILE%\.docker\ca.pem    Trust certs signed only by this CA
  --tlscert=%USERPROFILE%\.docker\cert.pem    Path to TLS certificate file
  --tlskey=%USERPROFILE%\.docker\key.pem      Path to TLS key file
  --tlsverify                                 Use TLS and verify the remote
  -v, --version                               Print version information and quit

Commands:
    attach    Attach to a running container
    build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    cp        Copy files/folders between a container and the local filesystem
    create    Create a new container
    diff      Inspect changes on a container's filesystem
    events    Get real time events from the server
    exec      Run a command in a running container
    export    Export a container's filesystem as a tar archive
    history   Show the history of an image
    images    List images
    import    Import the contents from a tarball to create a filesystem image
    info      Display system-wide information
    inspect   Return low-level information on a container, image or task
    kill      Kill one or more running containers
    load      Load an image from a tar archive or STDIN
    login     Log in to a Docker registry.
    logout    Log out from a Docker registry.
    logs      Fetch the logs of a container
    network   Manage Docker networks
    node      Manage Docker Swarm nodes
    pause     Pause all processes within one or more containers
    port      List port mappings or a specific mapping for the container
    ps        List containers
    pull      Pull an image or a repository from a registry
    push      Push an image or a repository to a registry
    rename    Rename a container
    restart   Restart a container
    rm        Remove one or more containers
    rmi       Remove one or more images
    run       Run a command in a new container
    save      Save one or more images to a tar archive (streamed to STDOUT by default)
    search    Search the Docker Hub for images
    service   Manage Docker services
    start     Start one or more stopped containers
    stats     Display a live stream of container(s) resource usage statistics
    stop      Stop one or more running containers
    swarm     Manage Docker Swarm
    tag       Tag an image into a repository
    top       Display the running processes of a container
    unpause   Unpause all processes within one or more containers
    update    Update configuration of one or more containers
    version   Show the Docker version information
    volume    Manage Docker volumes
    wait      Block until a container stops, then print its exit code

Run 'docker COMMAND --help' for more information on a command.

使用Docker搭建Galaxy生物信息平台

首先我们需要确认Docker是否存在这个平台

$ [sudo] docker search galaxy
NAME                                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
bgruening/galaxy-stable                              Galaxy Docker Image                             18                   [OK]
bgruening/galaxy-deeptools                                                                           5                    [OK]
bgruening/galaxy-rna-workbench                                                                       2                    [OK]
......

通过NAME这一列我们可以找到所需要的镜像(images)为bgruening/galaxy-stable,也可以去Docker Hub进行查找。

Paste_Image.png
Paste_Image.png

在作者的Docker Hub页面上会有该镜像的具体使用方法。

找到进行之后,就可以通过pull下载该镜像:

> docker pull bgruening/galaxy-stable

随后通过该镜像在本地运行Galaxy服务:

>docker run --name mygalaxy -d -p 8080:80 -p 8021:21 -p 8022:22 bgruening/galaxy-stable
--name xxxx: 指定该容器名,否则随机生成
-d : 作为一种服务在后台运行
-p 外部端口:内部端口 : 将外部端口绑定到内部端口,实现从浏览器访问Galaxy

在浏览器输入localhost:8080,就可以访问了。

Galaxy

当然我们可能还需要在Galaxy中添加管理,修改配置,这时候就需要交互式的运行docker。

docker run -i -t bgruening/galaxy-stable /bin/bash

更详细的了解如何管理服务

光是学会安装运行还不够,我们还需要了解服务的运行状态,这里就要介绍另外几个command: ps, top, logs, port

> docker ps -l #可以查看最近运行的服务
> docker port mygalaxy # 查看mygalaxy的端口转发
> docker logs mygalaxy # 了解mygalaxy的运行日志
> docker top  mygalaxy # 了解mygalaxy的运行进程

如何想暂停服务该怎么办?暂停之后有需要重新开启呢?

>docker stop mygalaxy
>docker start mygalaxy

卸载Galaxy

当你用了Docker版的Galaxy后感觉还是不太适合,那应该如何卸载呢?首先是停止服务,然后删除容器,然后删除镜像.

docker stop mygalaxy
docker rm mygalaxy
docker rmi bgruening/galaxy-stable

总结

本文主要介绍了一种在Windows上搭建Galaxy的一种方法,介绍Docker的几个指令:search, pull, run, ps, port, top, logs, stop, start等指令,更多Docker和Galaxy相关内容请翻阅参考资料。

参考资料

https://docs.docker.com/docker-for-windows/
https://hub.docker.com/r/bgruening/galaxy-stable/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 156,265评论 4 359
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,274评论 1 288
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 106,087评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,479评论 0 203
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 51,782评论 3 285
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,218评论 1 207
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,594评论 2 309
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,316评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 33,955评论 1 237
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,274评论 2 240
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,803评论 1 255
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,177评论 2 250
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,732评论 3 229
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 25,953评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,687评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,263评论 2 267
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,189评论 2 258

推荐阅读更多精彩内容

  • Docker — 云时代的程序分发方式 要说最近一年云计算业界有什么大事件?Google Compute Engi...
    ahohoho阅读 15,414评论 15 147
  • 0. 前言 docker是什么?docker是用GO语言开发的应用容器引擎,基于容器化,沙箱机制的应用部署技术。可...
    sessionboy阅读 3,793评论 2 49
  • 一、Docker 简介 Docker 两个主要部件:Docker: 开源的容器虚拟化平台Docker Hub: 用...
    R_X阅读 4,342评论 0 27
  • 燃点起一支残烛 竟然又提笔忘字 每天瞎忙到不知所踪 泪尽 烛尽 还是诗尽
    师荔阅读 286评论 0 7
  • 前任最近要去看演唱会 恰好看场演唱会一直是我的愿望 如今被他一提 我的内心即刻蠢蠢欲动 我以为我是抢不到低价票 我...
    函庭阅读 128评论 0 0