前幾天再看新買的《python Web開發(fā)實(shí)踐》時發(fā)現(xiàn)一個神奇的工具---Docker撵术,官網(wǎng)介紹是
Docker is the world's leading software containerization platform
我不禁想到生物信息學(xué)中有許多軟件都要在類unix平臺上運(yùn)行炬转,僅有部分移植到Windows上听诸。所以在要想在Windows上運(yùn)行這些沒有移植的軟件寓涨,要么需要虛擬出一個Linux系統(tǒng),要不就是利用Windows10上一個新特性--內(nèi)置ubuntu系統(tǒng)。
所以由于Docker的特性,就多了一種在windows上運(yùn)行生物信息軟件的方法
安裝
運(yùn)行Docker的第一步就是安裝宿饱。Docker最在僅能在類unix系統(tǒng)運(yùn)行,后來移植到Windows平臺脚祟,不過要在Windows上安裝Docker也要滿足2個要求:
- Windows10 64位
- Hyper V
不滿足的話可以用Docker Toolbox替代谬以。
滿足以上條件后只要下載InstallDocker.msi并運(yùn)行就行了。
然后打開powershell由桌,輸入一下指令檢查是否安裝成功
> docker version
> docker-compose --version
> docker-machine --version
如果以上命令都沒有報錯則安裝完成为黎。此外在命令行直接輸入docker就會出現(xiàn)docker的參數(shù)說明,具體使用方法見后面的案例行您。
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生物信息平臺
首先我們需要確認(rèn)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進(jìn)行查找。
在作者的Docker Hub頁面上會有該鏡像的具體使用方法邑雅。
找到進(jìn)行之后,就可以通過pull
下載該鏡像:
> docker pull bgruening/galaxy-stable
隨后通過該鏡像在本地運(yùn)行Galaxy服務(wù):
>docker run --name mygalaxy -d -p 8080:80 -p 8021:21 -p 8022:22 bgruening/galaxy-stable
--name xxxx: 指定該容器名妈经,否則隨機(jī)生成
-d : 作為一種服務(wù)在后臺運(yùn)行
-p 外部端口:內(nèi)部端口 : 將外部端口綁定到內(nèi)部端口淮野,實(shí)現(xiàn)從瀏覽器訪問Galaxy
在瀏覽器輸入localhost:8080,就可以訪問了吹泡。
當(dāng)然我們可能還需要在Galaxy中添加管理骤星,修改配置,這時候就需要交互式的運(yùn)行docker爆哑。
docker run -i -t bgruening/galaxy-stable /bin/bash
更詳細(xì)的了解如何管理服務(wù)
光是學(xué)會安裝運(yùn)行還不夠洞难,我們還需要了解服務(wù)的運(yùn)行狀態(tài),這里就要介紹另外幾個command: ps, top, logs, port
> docker ps -l #可以查看最近運(yùn)行的服務(wù)
> docker port mygalaxy # 查看mygalaxy的端口轉(zhuǎn)發(fā)
> docker logs mygalaxy # 了解mygalaxy的運(yùn)行日志
> docker top mygalaxy # 了解mygalaxy的運(yùn)行進(jìn)程
如何想暫停服務(wù)該怎么辦揭朝?暫停之后有需要重新開啟呢队贱?
>docker stop mygalaxy
>docker start mygalaxy
卸載Galaxy
當(dāng)你用了Docker版的Galaxy后感覺還是不太適合色冀,那應(yīng)該如何卸載呢?首先是停止服務(wù)柱嫌,然后刪除容器锋恬,然后刪除鏡像.
docker stop mygalaxy
docker rm mygalaxy
docker rmi bgruening/galaxy-stable
總結(jié)
本文主要介紹了一種在Windows上搭建Galaxy的一種方法,介紹Docker的幾個指令:search, pull, run, ps, port, top, logs, stop, start等指令编丘,更多Docker和Galaxy相關(guān)內(nèi)容請翻閱參考資料与学。
參考資料
https://docs.docker.com/docker-for-windows/
https://hub.docker.com/r/bgruening/galaxy-stable/