Docker bioinformatics IDE: RStudio, JupyterLab, VS Code, and persistent projects/packages/data.
70
A root-operated Docker development environment for bioinformatics work. One container provides:
This setup is intended for a trusted local development machine. All interactive sessions run as root in the container. You do not need sudo, su, or pip install --user when installing software in the container.
Running IDEs as root is convenient for a single-user local research environment, but it is not appropriate to expose directly to a network or the internet. The run command in this README binds all services to 127.0.0.1, so they are reachable only from the same computer.
Use strong, unique values for PASSWORD and JUPYTER_TOKEN. Do not replace 127.0.0.1 with 0.0.0.0 unless you first add suitable TLS and network-level access controls.
docker commandsDockerfileVerify Docker is available:
docker version
The quickest way to start is to pull the published image:
docker pull bhagesh/bioworkspace:latest
Confirm it is available locally:
docker image ls bhagesh/bioworkspace
Clone the repository if you want to inspect or modify the Dockerfile:
git clone https://github.com/bhagesh-h/bioworkspace.git
cd bioworkspace
Build a local image with the same Docker Hub image name:
docker build \
-f Dockerfile \
-t bioworkspace \
.
The first build downloads the Rocker base image, code-server, micromamba, Python, and JupyterLab. Later builds use Docker's cache unless you change an earlier Dockerfile layer.
Create persistent host folders. Run this from the directory where you want your projects and package libraries stored:
mkdir -p workspace data r-library python-packages jupyter-config code-config
| Local directory | Mounted container directory | Purpose |
|---|---|---|
workspace/ | /workspace | Jupyter notebooks, scripts, Git repositories, results, reports, and project files |
data/ | /data | Raw data, reference files, intermediate data, and exported results |
r-library/ | /opt/R/library | R and Bioconductor packages installed while the container runs |
python-packages/ | /opt/python | Python packages and command-line tools installed with pip install |
jupyter-config/ | /root/.jupyter | Jupyter settings, kernelspecs, preferences, and saved workspaces |
code-config/ | /root/.config/code-server | code-server settings and extensions |
Do not mount a host directory on /bin, /usr/bin, /opt/jupyter/bin, or /opt/jupyter. Those locations contain executables supplied by the base image, and a bind mount would hide them.
Run this command from the directory containing workspace/, data/, and the other persistent folders:
docker run --rm -it \
--name bioworkspace \
-p 127.0.0.1:8787:8787 \
-p 127.0.0.1:8080:8080 \
-p 127.0.0.1:8888:8888 \
-e PASSWORD='replace-with-a-strong-password' \
-e JUPYTER_TOKEN='replace-with-a-separate-strong-token' \
--mount type=bind,src="$(pwd)/workspace",dst=/workspace \
--mount type=bind,src="$(pwd)/data",dst=/data \
--mount type=bind,src="$(pwd)/r-library",dst=/opt/R/library \
--mount type=bind,src="$(pwd)/python-packages",dst=/opt/python \
--mount type=bind,src="$(pwd)/jupyter-config",dst=/root/.jupyter \
--mount type=bind,src="$(pwd)/code-config",dst=/root/.config/code-server \
bhagesh/bioworkspace:latest
Use ${PWD} rather than $(pwd) if needed:
docker run --rm -it `
--name bioworkspace `
-p 127.0.0.1:8787:8787 `
-p 127.0.0.1:8080:8080 `
-p 127.0.0.1:8888:8888 `
-e PASSWORD='replace-with-a-strong-password' `
-e JUPYTER_TOKEN='replace-with-a-separate-strong-token' `
--mount type=bind,src="${PWD}/workspace",dst=/workspace `
--mount type=bind,src="${PWD}/data",dst=/data `
--mount type=bind,src="${PWD}/r-library",dst=/opt/R/library `
--mount type=bind,src="${PWD}/python-packages",dst=/opt/python `
--mount type=bind,src="${PWD}/jupyter-config",dst=/root/.jupyter `
--mount type=bind,src="${PWD}/code-config",dst=/root/.config/code-server `
bhagesh/bioworkspace:latest
The terminal running this command shows service logs. Stop the container with Ctrl+C. Because --rm is used, the container itself is deleted when it stops; the mounted host directories remain intact.
| Service | Address | Login |
|---|---|---|
| RStudio Server | http://localhost:8787 | User: root; password: the value of PASSWORD |
| VS Code / code-server | http://localhost:8080 | Password: the value of PASSWORD |
| JupyterLab | http://localhost:8888 | Token: the value of JUPYTER_TOKEN |
JupyterLab opens files from /workspace. In RStudio and code-server, open /workspace as the working project folder. Input data is available at /data.
All terminals and notebook kernels run as root. Use ordinary installation commands.
Run these from a JupyterLab terminal, code-server terminal, RStudio terminal, or docker exec shell:
pip install scanpy anndata muon pandas pyarrow
pip install biopython pysam pybedtools
The image configures pip to install into /opt/python. Since that directory is bind-mounted to python-packages/, installed packages and executable tools persist on the host. Do not add --user.
python -c "import scanpy; print(scanpy.__file__)"
In RStudio, an R notebook, or an R terminal:
install.packages("data.table", repos = "https://cloud.r-project.org")
install.packages(c("ggplot2", "tidyverse"), repos = "https://cloud.r-project.org")
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager", repos = "https://cloud.r-project.org")
}
BiocManager::install(c("DESeq2", "SingleCellExperiment", "GenomicRanges"))
R_LIBS_USER=/opt/R/library makes these packages persist in r-library/.
Install OS packages without sudo:
apt-get update
apt-get install -y samtools bedtools bcftools tabix
Packages installed with apt-get modify the running container only and disappear when it is removed. For reproducibility, add frequently used OS packages to the Dockerfile's apt-get install block, then rebuild the image.
The default data/ mount is read/write. If it contains raw sequencing data or reference files that should not be modified, mount it read-only:
--mount type=bind,src="$(pwd)/data",dst=/data,readonly
Write derived files to /workspace/results, which maps to local workspace/results:
mkdir -p /workspace/results
samtools flagstat /data/sample.bam > /workspace/results/sample.flagstat.txt
Open a root shell in the running container:
docker exec -it bioworkspace bash
Useful checks:
whoami
python --version
R --version
jupyter lab path
whoami should return root.
Do not set JUPYTERLAB_DIR in this image. It overrides JupyterLab's installed application directory. If it points to an empty mounted directory, JupyterLab fails with JupyterLab application assets not found.
The application assets supplied by the micromamba environment remain at /opt/jupyter/share/jupyter/lab. Persist user configuration by mounting /root/.jupyter, as shown above, rather than overriding the application directory.
Press Ctrl+C to stop a foreground container, then run the same docker run command to restart it. Work, data, installed R/Python packages, and IDE configuration remain in the local bind-mounted folders.
For a detached container, stop it with:
docker stop bioworkspace
List Docker resources:
docker ps -a
docker image ls
Remove the local image if no longer needed:
docker image rm bhagesh/bioworkspace:latest
This does not remove workspace/, data/, or any other local persistent folders.
Content type
Image
Digest
sha256:cdcb89339…
Size
1.3 GB
Last updated
3 months ago
docker pull bhagesh/bioworkspace