docker配置的基本操作
docker重启以及docker容器重启:
#docker重启
service docker restart
#docker容器重启/启动
docker restart rstudio_new
docker start rstudio_new
docker的停止以及启动
#停止容器:
docker stop {container}
#停止docker:
systemctl stop docker
#启动docker:
systemctl start docker
从宿主机到docker之间复制文件:
docker cp ./sources.list 2f46782c6b8d:/etc/apt
显示docker container的id号:
docker ps
包含已停止容器:
docker ps -a
只列出容器号:
docker ps -q
进入某个docker 容器:
docker run -it ubuntu /bin/bash;docker exec -it 69d1 /bin/bash
普通用户身份登入docker:
docker exec -it -u WRJ rstudio_new /bin/bash
关闭与删除:
docker stop 【容器ID】
docker rm 【容器ID】
运行docker:
docker run --name singlecell_analysis --net=host -itd ubuntu
这里的--net要加上,不然可能运行失败。
rstudio-server的安装:官网提供了docker的安装镜像,直接pull就行,完整命令:
docker run --name rstudio_new -d \
-p 8790:8787 \
-e USER=wrj_rstudio \
-e PASSWORD={password} \
-e USERID=1000 \
-e GROUPID=1000 \
-e ADD=shiny \
-v /data:/mnt/ \
rocker/rstudio
这里注意最好不要把系统文件直接挂载到home目录下,容易报错
新的docker,rstudio配置
首先登入:
docker exec -it rstudio_new /bin/bash
之后更新:
apt-get update
apt-get upgrade
之后安装一些系统包:
apt-get install -y vim
一些报错和解决办法
- igraph:安装时没有报错,load的时候报错,libglpk.so.40: cannot open shared object file: No such file or directory
解决方法:
apt-get install -y glpk-utils libglpk-dev glpk-doc
- sf:类似问题,报错:libudunits2.so.0: cannot open shared object file: No such file or directory
apt-get install -y libudunits2-dev
apt-get install -y libproj-dev
apt-get install -y libgdal-dev
apt-get install -y libx11-dev
apt-get install -y libmagick++-dev
apt-get install -y libharfbuzz-dev libfribidi-dev
其他安装包:
sudo apt-get install gcc g++ liblapack-dev libblas-dev gfortran zlib1g-dev libpng-dev libxml2-dev libgsl-dev gdal-bin libgdal-dev libcairo2-dev libbz2-dev libnode-dev cmake libudunits2-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev ssh libharfbuzz-dev libfribidi-dev libfontconfig1-dev patch tcl tk
所有安装包:
sudo apt-get install -y glpk-utils libglpk-dev glpk-doc libudunits2-dev libproj-dev libgdal-dev libx11-dev libmagick++-dev libharfbuzz-dev libfribidi-dev gcc g++ liblapack-dev libblas-dev gfortran zlib1g-dev libpng-dev libxml2-dev libgsl-dev gdal-bin libgdal-dev libcairo2-dev libbz2-dev libnode-dev cmake libudunits2-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev ssh libharfbuzz-dev libfribidi-dev libfontconfig1-dev patch tcl tk
之后手动安装github上的包需要预先安装的一些R包
install.packages(c("Seurat","BiocManager","qs","assertthat", "ggrastr", "grr", "lme4", "pbmcapply", "pscl", "rsample", "RhpcBLASctl", "RcppHNSW", "spdep", "speedglm", "terra","MCMCpack", "fields", "wrMisc", "concaveman", "scatterpie", "ggcorrplot", "nnls", "RcppML", "NMF","zeallot", "imager", "raster", "magick", "shinyjs","proj4", "ash", "extrafont","ggfittext","ggpubr","intrinsicDimension", "parallelDist", "proxyC", "R.cache", "R.utils","qpdf","ggiraph"))
BiocManager::install(c("Biobase","monocle","SingleCellExperiment","batchelor","BiocParallel","DelayedArray","DelayedMatrixStats","HDF5Array","S4Vectors","SummarizedExperiment","TOAST","ComplexHeatmap","EnhancedVolcano","AnnotationDbi","clusterProfiler","glmGamPoi","RCircos"))
BiocManager::install(c("NMF","Signac","pheatmap","Deseq2","hdf5r","rhdf5","AUCell","GENIE3","networkD3","devtools","WGCNA","biomaRt","simplifyEnrichment","slingshot","ggalluvial","svglite","sna","ggnetwork","tidyverse","DESeq2","RcisTarget","amap","vcfR","sparsesvd","rsconnect","DT","ggdendro","hdf5r","shinyhelper","stringdist","ggpp",'colorRamps','factoextra','Mfuzz','org.Mm.eg.db','expm','egg','openxlsx'))
#NMF需要等Biobase安装后才可以安装
#Signac需要Rsamtools装完后才可以安装
安装包安装:
setwd("/mnt/R_package")
install.packages(c("monocle3-master","STUtility-master","CARD-master","ggdensity-main","ggalt-master"),type="source",repos=NULL)
install.packages(c("DoubletFinder-master","seurat-disk-master","ggunchull-main","ggdendro-main","ggpointdensity-master","ggdensity-main","SCP-main","DoubletFinder-master"),type="source",repos=NULL)
install.packages(c("CellChat-master","ggh4x-main","VoxHunt","SCENIC-master","harmony-master"),type="source",repos=NULL)
docker里面新建用户
比较麻烦,需要自动操作,举例:(用户组和用户编号根据需求指定)
首先新建用户组:
groupadd -g 1006 {groupname}
之后新建用户:
useradd -u 1005 -g 1006 WRJ
(用useradd -m -u 1007 -g 1006 wrj_new的方法,就不存在后续的家目录以及显示问题了)
修改密码:
passwd WRJ
建立主目录并增加bash权限:
mkdir /home/WRJ
chown WRJ:{groupname} /home/WRJ
usermod -s /bin/bash WRJ
结果发现新建的用户家目录里没有bashrc,无法显示文件分类颜色,直接从另外一个用户地下copy了一个过来,并更改所属用户:
chown username:groupname .bashrc
建议以后还是用adduser功能,可以自动化创建这一系列文件。