Skip to content

Commit 457e914

Browse files
committed
Updates for Docker (#947, #948)
* Update Dockerfiles and image build script to match output * Add full Dockerfile * Update Docker docs
1 parent 627a5c5 commit 457e914

File tree

6 files changed

+77
-21
lines changed

6 files changed

+77
-21
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ You can reach us at [AllenCenterCovertLab](mailto:[email protected]
99

1010
See [docs/README.md](docs/README.md) for more info on setting up and running the model.
1111

12-
In short, there are two alternative setups to run the model: inside a Docker container vs. in a manually constructed `pyenv` virtual environment.
13-
12+
In short, there are two alternative setups to run the model: inside a Docker container vs. in a manually constructed `pyenv` virtual environment. With Docker, you can start running a simulation with three commands:
13+
1. Pull the Docker image:
14+
```shell script
15+
docker pull docker.pkg.github.com/covertlab/wholecellecolirelease/wcm-full:latest
16+
```
17+
1. Run the Docker container:
18+
```shell script
19+
docker run --name=wcm -it --rm docker.pkg.github.com/covertlab/wholecellecolirelease/wcm-full
20+
```
21+
1. Inside the container, run the model:
22+
```shell script
23+
python runscripts/manual/runSim.py
24+
```
1425

1526
## Quick start
1627

17-
When running this code, prepare with these steps (the wcm-code Docker container already prepares this for you):
28+
When running this code, prepare with these steps (the wcm-full Docker container already prepares this for you):
1829

1930
1. `cd` to the top level of your `wcEcoli` directory.
2031
2. Set the `$PYTHONPATH`:
@@ -46,7 +57,7 @@ These scripts have command line interfaces built on Python's `argparse`, so you
4657
**NOTE:** _Use the `-h` or `--help` switch to get complete, up-to-date documentation on the command line options._ Below are just _some_ of the command line options.
4758

4859

49-
To run the parameter calculator (ParCa), which is needed to prepare input data for the simulation:
60+
To run the parameter calculator (ParCa), which is needed to prepare input data for the simulation (this step has already been run when building the wcm-full Docker image and can be skipped if running a container from that image):
5061
```bash
5162
python runscripts/manual/runFitter.py [-h] [--cpus CPUS] [sim_outdir]
5263
```

cloud/build-containers.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
#!/bin/sh
1+
#! /usr/bin/env bash
22
# Build the WCM Docker container images locally.
33
#
44
# ASSUMES: The current working dir is the wcEcoli/ project root.
55

66
set -eu
77

8+
# On macOS, build with `NO_AVX2=1` to avoid the OpenBLAS 0.3.6+ self-test failures
9+
# and bad results when building with Docker Desktop on macOS.
10+
if [ "$(uname -s)" == Darwin ]; then NO_AVX2=1; else NO_AVX2=0; fi
11+
812
# Docker image #1: The Python runtime environment.
9-
docker build -f cloud/docker/runtime/Dockerfile -t wcm-runtime .
13+
docker build -f cloud/docker/runtime/Dockerfile -t wcm-runtime \
14+
--build-arg NO_AVX2=$NO_AVX2 .
1015

1116
# Docker image #2: The Whole Cell Model code on the runtime environment.
1217
# See this Dockerfile for usage instructions.
1318
docker build -f cloud/docker/wholecell/Dockerfile -t wcm-code .
19+
20+
# Docker image #3: The Whole Cell Model code with parameters calculated, ready for sims.
21+
# See this Dockerfile for usage instructions.
22+
docker build -f cloud/docker/full/Dockerfile -t wcm-full .

cloud/docker/full/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Container image #3: wcm-full.
2+
# This Dockerfile builds a container image with the full Whole Cell Model, ready
3+
# to run simulations, layered on the wcm-code image.
4+
#
5+
# To build locally from the wcEcoli/ project root directory:
6+
#
7+
# > docker build -f cloud/docker/full/Dockerfile -t wcm-full .
8+
#
9+
# After building locally you can start up a new container from the image:
10+
#
11+
# > docker run --name wcm -it --rm wcm-full
12+
#
13+
# It will start a shell where you can execute commands:
14+
#
15+
# # nosetests
16+
#
17+
# If this succeeds you should be good to go, e.g.:
18+
#
19+
# # python runscripts/manual/runSim.py
20+
21+
22+
ARG from=wcm-code:latest
23+
FROM ${from}
24+
25+
RUN python runscripts/manual/runFitter.py
26+
27+
CMD ["/bin/bash"]

cloud/docker/runtime/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
# Add option `--build-arg from=ABC` to build from a different base image but
1818
# DO NOT USE an alpine base since the simulation math comes out different!
1919
# See https://pythonspeed.com/articles/alpine-docker-python/ for more reasons.
20-
ARG from=python:2.7.16
20+
ARG from=python:2.7.16-stretch
2121
FROM ${from}
2222

2323
# Option `--build-arg NO_AVX2=1` controls OpenBLAS' use of AVX2 instructions:
2424
#
25-
# * NO_AVX2=1 is needed to build or run properly in Docker-for-Mac due to a
25+
# * NO_AVX2=1 is needed to build properly in Docker-for-Mac due to a
2626
# Docker bug.
2727
# * NO_AVX2=0 reportedly runs 20-30% faster BLAS if you're sure it'll only
28-
# build and run in Docker-for-Linux, but this only saves ~7% in a cell sim.
28+
# build in Docker-for-Linux, but this only saves ~7% in a cell sim.
2929
#
3030
# Docker-for-Mac bug:
3131
# https://github.com/xianyi/OpenBLAS/issues/2244
3232
# https://github.com/docker/for-mac/issues/4576
3333
# https://github.com/machyve/xhyve/issues/171
34-
ARG NO_AVX2=1
34+
ARG NO_AVX2=0
3535
ENV NO_AVX2="$NO_AVX2"
3636

3737
RUN apt-get update \

cloud/docker/wholecell/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ ENV PYTHONPATH=/wcEcoli
4141
RUN umask 000 && rm -rf fixtures && mkdir fixtures \
4242
&& chmod a+rwx reconstruction/ecoli/dataclasses/process
4343

44-
RUN echo 'cat cloud/docker/welcome.txt' >> $HOME/.bashrc
44+
# Show a welcome message with tips on wcEcoli.
45+
# Copy .bashrc into / for users w/o home dirs such as `docker run --user ...`
46+
RUN (echo 'cat cloud/docker/welcome.txt' >> ~/.bashrc \
47+
&& cp ~/.bashrc /)
4548

4649
CMD ["/bin/bash"]

docs/README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ These are the docs for a variety of topics on the Whole Cell Model.
77
There are two alternative ways to set up to run the model:
88

99
1. **Docker Container:** Install the
10-
[Docker Desktop software](https://www.docker.com/products/docker-desktop),
11-
build a Docker Image, then run the Docker Image as a Container.
12-
13-
Build the wcEcoli Docker Image this way:
10+
[Docker Desktop software](https://www.docker.com/products/docker-desktop)
11+
and run the Docker Image as a Container.
1412

13+
Pull the full docker image from the package registry in this repo:
1514
```shell script
16-
cd $YOUR_CODE_PROJECTS_DIR/wcEcoli # or wherever you cloned the wcEcoli project to
17-
cloud/build-containers.sh
15+
docker pull docker.pkg.github.com/covertlab/wholecellecolirelease/wcm-full:latest
1816
```
1917

2018
You can then run the wcEcoli model inside the Container like this:
2119

2220
```shell script
23-
docker run --name=wcm -it --rm wcm-code
21+
docker run --name=wcm -it --rm docker.pkg.github.com/covertlab/wholecellecolirelease/wcm-full
2422
```
2523

2624
The `-it` option starts an interactive shell.
@@ -30,10 +28,11 @@ There are two alternative ways to set up to run the model:
3028
exit so you don't have to remember to delete old Containers.
3129

3230
You can mount your local directory `wcEcoli/out/` into the Container to preserve the
33-
program's output files when the Container exits:
31+
program's output files when the Container exits - just be sure to provide a full path
32+
to `out/` (eg. `$PWD/out`), not just a relative path from your current directory:
3433

3534
```shell script
36-
docker run --name=wcm -v $PWD/out:/wcEcoli/out -it wcm-code
35+
docker run --name=wcm -v $PWD/out:/wcEcoli/out -it docker.pkg.github.com/covertlab/wholecellecolirelease/wcm-full
3736
```
3837

3938
In this case, the output files will be owned by root. You can fix
@@ -45,7 +44,7 @@ There are two alternative ways to set up to run the model:
4544

4645
**NOTE:** If you encounter memory issues while using Docker Desktop (the default allocated memory is 2GB) and the simulation processes get killed midway, click the Docker icon > Preferences > Advanced > adjust memory to 4GB.
4746

48-
**NOTE:** Docker Desktop for Windows is not currently compatible with VirtualBox. If you use VirtualBox, try installing the legacy [Docker Toolbox](https://github.com/docker/toolbox/releases) instead. You may also need to adjust the memory allocated to the VirtualBox VM (named 'default') that gets created. In VirtualBox, select the 'default' VM and under system, change the base memory from 1 GB to 4 GB.
47+
**NOTE:** When setting up Docker Desktop for Windows, it is best to [use the WSL2 backend](https://docs.docker.com/docker-for-windows/wsl/). If not, you might run into compatability issues when trying to run Docker, especially if you have VirtualBox installed, which could require using the legacy [Docker Toolbox](https://github.com/docker/toolbox/releases).
4948

5049
Inside the Container you can then run commands like these:
5150

@@ -58,6 +57,13 @@ There are two alternative ways to set up to run the model:
5857
**Tip:** Eventually, you'll want to delete the Docker Image. Refer to the
5958
commands `docker image prune`, `docker image ls`, and `docker image rm`.
6059

60+
**Tip:** You can build your own Docker image instead of the one provided using these steps:
61+
62+
```shell script
63+
cd $YOUR_CODE_PROJECTS_DIR/wcEcoli # or wherever you cloned the wcEcoli project to
64+
cloud/build-containers.sh
65+
```
66+
6167
2. **Python virtual environment:** Follow [Required development tools](dev-tools.md) to install the development tools including pyenv, gcc, make, and git, then follow [Creating the "pyenv" runtime environment](create-pyenv.md) to set up the Python runtime virtual environment for the model including binary libraries and Python packages.
6268

6369
You can then run wcEcoli in this Python virtualenv.

0 commit comments

Comments
 (0)