查看原文
其他

利用Docker搭建Galaxy

2017-07-15 徐洲更 生信媛

这是我去年10月写的一篇文章,现在发现Docker在生物信息学上的用处真是越来越大了,所以在这里发一次。

前几天再看新买的《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进行查找。


在作者的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中添加管理,修改配置,这时候就需要交互式的运行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/

推荐阅读

用了Docker,妈妈再也不担心我的软件安装了 - 基础篇

我学会docker啦!希望你也可以学会


目前,从零开始学习转录组正在火热连载中,不要半途而废哦。世上没有白走的路,每一步都算数

(伪)从零开始学转录组:软件安装

(伪)从零开始学转录组:读文章拿到测序数据

转录组入门(3):了解fastq测序数据 (一不小心破坏队形了)

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存