VScode+Docker学习

2021-08-16  本文已影响0人  哇珍

参考:Analysis of single cell RNA-seq data
【高清】2020黑马程序员 Docker讲解_哔哩哔哩_bilibili
Using the RStudio image · rocker-org/rocker Wiki · GitHub
Docker 从入门到实践 (docker-practice.com)
docker命令大全
Docker 镜像、容器 常用命令,容器与宿主服务器文件复制
docker docs

docker部署rocker/rstudio

docker run --rm \
           -p 9290:8787 \
           -d \
           --name wangzh \
           -v /home/zhanglab_wangzh:/home \
           -e USER=wangzh \
           -e ROOT=TRUE \
           -e PASSWORD=123456 \
           rocker/rstudio:latest

9290是我自己的端口,8787是rocker/rstudio的端口;命名容器为wangzh;将/home/zhanglab_wangzh的内容复制到容器的/home;登录名为wangzh;
ROOT=TRUE表示从 RStudio 中启用 root,用户在未先进入容器的情况下使用 apt-get 安装二进制库。

Clean up (--rm)

By default a container’s file system persists even after the container exits. This makes debugging a lot easier (since you can inspect the final state) and you retain all your data by default. But if you are running short-term foreground processes, these container file systems can really pile up. If instead you’d like Docker to automatically clean up the container and remove the file system when the container exits, you can add the --rm flag:

--rm=false: Automatically remove the container when it exits

Note

If you set the --rm flag, Docker also removes the anonymous volumes associated with the container when the container is removed. This is similar to running docker rm -v my-container. Only volumes that are specified without a name are removed. For example, when running:

docker run --rm -v /foo -v awesome:/bar busybox top

the volume for /foo will be removed, but the volume for /bar will not. Volumes inherited via --volumes-from will be removed with the same logic: if the original volume was specified with a name it will not be removed.

进入容器

docker exec -it wangzh /bin/bash

文件传输(不推荐!!!!不到万不得已不要用啊!!!)

将之前的服务器上的数据拷贝到rocker/rstudio镜像上:

docker cp 本地文件路径 ID全称:容器路径(这东西会导致用户改变!!!简直是个大坑!!!直接将我的用户组从zhanglab_wangzh改为了dell)

docker cp /home/zhanglab_wangzh 109984638e04:/home/wangzh/

同理,如果是容器传输文件到本地的话,反过来就好了:

docker cp ID全称:容器文件路径 本地路径

安装 R 系统外部依赖
许多 R 包有外部依赖,如 GSL, GDAL, JAGS,为了安装它们,你需要进行如下的操作:
具体的参考:https://jsta.github.io/r-docker-tutorial/03-install-packages.html

docker ps # find the ID of the running container you want to add a package to
docker exec -it <container-id> bash # a docker command to start a bash shell in your container
apt-get install libgsl0-dev # install the package, in this case GSL

如果安装报错,先试试 apt-get update

Dockerfile安装R包

Update to R 4.1.0 · davetang/learning_docker@425cff3 · GitHub

到容器的指定地址:

https://www.youtube.com/watch?v=lfG8cTqRRNA
https://github.com/SymbolixAU/r_docker_hello
https://github.com/SymbolixAU/useR_docker_tutorial

上一篇下一篇

猜你喜欢

热点阅读