Skip to content

Commit 9a225cd

Browse files
committed
Clean up and vet Docker page
And move it into /learn, since it's an ImageJ usage topic. The docs are Fiji-specific right now, unfortunately, but the plan is to generalize the Docker image(s) to be ImageJ2, not only Fiji.
1 parent f5f95ab commit 9a225cd

File tree

1 file changed

+73
-58
lines changed

1 file changed

+73
-58
lines changed

_pages/plugins/docker.md renamed to _pages/learn/docker.md

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
---
2-
mediawiki: Docker
32
title: Docker
4-
categories: [Uncategorized]
53
---
64

75
[Docker](https://www.docker.com/whatisdocker/) provides a platform for distribution of application state. This facilitates the highest level of scientific [reproducibility](/develop/architecture#reproducible-builds) - as a Docker image can bundle operating system, Java version, update site and plugin state, and even sample data. These images can then be reused by remote users and scientists worldwide, with no dependency concerns (beyond Docker itself).
@@ -13,30 +11,36 @@ You will need to [install Docker](https://docs.docker.com/installation/#installa
1311
# How to use the Fiji Docker images
1412

1513
The base Fiji images are provided on [Docker Hub](https://registry.hub.docker.com/u/fiji/fiji/). These images call the Fiji executable by default. For example:
16-
17-
` docker run -it --rm fiji/fiji`
14+
```shell
15+
docker run -it --rm fiji/fiji
16+
```
1817

1918
will call the default Fiji image, attempting to open the ImageJ UI with Java 7.
2019

2120
Several [tags](https://registry.hub.docker.com/u/fiji/fiji/tags/manage/) are provided to run Fiji with different Java versions. For example, if you wanted to run with Oracle's Java 6, you would use:
22-
23-
` docker run -it --rm fiji/fiji:fiji-oracle-jdk6`
24-
25-
**Important** - without some extra setup, there is no display used by Docker. So if you just tried one of the above commands, you likely got an error:
26-
27-
` No GUI detected. Falling back to headless mode.`
28-
21+
```shell
22+
docker run -it --rm fiji/fiji:fiji-oracle-jdk6
23+
```
24+
25+
{% include notice icon='warning' content="
26+
Without some extra setup, there is no display used by Docker. So if you just tried one of the above commands, you likely got an error:
27+
```
28+
No GUI detected. Falling back to headless mode.
29+
```
2930
The following sections cover [headless](#running-headless) and [graphical](#running-the-ui) uses.
31+
" %}
3032

3133
# Running headless
3234

3335
Running ImageJ headlessly in Docker is not much different than normal headless operation - see the [headless guide](/learn/headless) for general information. To start a headless ImageJ invocation from Docker, use:
34-
35-
` docker run -it --rm fiji/fiji fiji-linux64 --headless`
36+
```shell
37+
docker run -it --rm fiji/fiji fiji-linux64 --headless
38+
```
3639

3740
If you want to manually explore the Fiji Docker image, e.g. to install additional plugins or utility software, you can start the command prompt via:
38-
39-
` docker run -it --rm fiji/fiji bash`
41+
```shell
42+
docker run -it --rm fiji/fiji bash
43+
```
4044

4145
Just be sure to [commit any changes](https://docs.docker.com/userguide/dockerimages/#updating-and-committing-an-image)!
4246

@@ -52,30 +56,35 @@ We can adapt [this blog post](http://fabiorehm.com/blog/2014/09/11/running-gui-a
5256

5357
Use this Dockerfile as a starting point:
5458

55-
` # Modify this tag if a different java version is desired`
56-
` FROM fiji/fiji:fiji-openjdk-7`
57-
` # Replace 1000 with your user / group id`
58-
` RUN export uid=1000 gid=1000 && \`
59-
` mkdir -p /home/developer && \`
60-
` echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \`
61-
` echo "developer:x:${uid}:" >> /etc/group && \`
62-
` echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \`
63-
` chmod 0440 /etc/sudoers.d/developer && \`
64-
` chown ${uid}:${gid} -R /home/developer`
65-
` USER developer`
66-
` ENV HOME /home/developer`
67-
` CMD fiji-linux64`
59+
```docker
60+
# Modify this tag if a different java version is desired
61+
FROM fiji/fiji:fiji-openjdk-7
62+
# Replace 1000 with your user / group id
63+
RUN export uid=1000 gid=1000 && \
64+
mkdir -p /home/developer && \
65+
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
66+
echo "developer:x:${uid}:" >> /etc/group && \
67+
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
68+
chmod 0440 /etc/sudoers.d/developer && \
69+
chown ${uid}:${gid} -R /home/developer
70+
USER developer
71+
ENV HOME /home/developer
72+
CMD fiji-linux64
73+
```
6874

6975
Install the Dockerfile with:
70-
71-
` docker build -t fiji .`
76+
```shell
77+
docker build -t fiji .
78+
```
7279

7380
Run Fiji with:
7481

75-
` docker run -ti --rm \`
76-
` -e DISPLAY=$DISPLAY \`
77-
` -v /tmp/.X11-unix:/tmp/.X11-unix \`
78-
` fiji/fiji`
82+
```shell
83+
docker run -ti --rm \
84+
-e DISPLAY=$DISPLAY \
85+
-v /tmp/.X11-unix:/tmp/.X11-unix \
86+
fiji/fiji
87+
```
7988

8089
Which should pop up a window with Fiji running.
8190

@@ -91,46 +100,51 @@ First, you will need to install the following:
91100
2. [Homebrew-cask](https://github.com/caskroom/homebrew-cask)
92101

93102
Then, from a terminal, use Homebrew to install [socat](http://www.cyberciti.biz/faq/linux-unix-tcp-port-forwarding/) and [XQuartz](http://xquartz.macosforge.org/landing/) via:
94-
95-
` brew install socat`
96-
97-
` brew cask install xquartz`
103+
```shell
104+
brew install socat
105+
brew cask install xquartz
106+
```
98107

99108
Now open a new terminal window and type
100-
101-
` echo $DISPLAY`
102-
109+
```shell
110+
echo $DISPLAY
111+
```
103112
and ensure it is not empty (it should print something like `/private/tmp/com.apple.launchd.GYg5TvcMIf/org.macosforge.xquartz:0`).
104113

105114
Then run:
106-
107-
` ifconfig`
108-
115+
```shell
116+
ifconfig
117+
```
109118
which will print output that should end with something like:
110-
111-
` vboxnet0: flags=0000<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST>`
112-
` ether 00:00:00:00:00:00`
113-
` inet 192.168.15.2 netmask 0xffffffff broadcast 192.168.0.0`
119+
```
120+
vboxnet0: flags=0000<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST>
121+
ether 00:00:00:00:00:00
122+
inet 192.168.15.2 netmask 0xffffffff broadcast 192.168.0.0
123+
```
114124

115125
And take note of the ip address on the last line (`192.168.15.2` in this case).
116126

117127
Since you are using macOS it is assumed you are using [boot2docker](http://boot2docker.io/). Now, in the same terminal you started boot2docker, you should have set up the environment variables e.g. with
118-
119-
` $(boot2docker shellinit)`
128+
```shell
129+
$(boot2docker shellinit)
130+
```
120131

121132
From this same terminal, open XQuartz with:
122-
123-
` open -a XQuartz`
133+
```shell
134+
open -a XQuartz
135+
```
124136

125137
This will start up a new X11 session. You will want two X11 terminals open here (`Application > Terminal` to open a new X11 terminal).
126138

127139
In one X11 terminal, run:
128-
129-
` socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"`
140+
```shell
141+
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
142+
```
130143

131144
to start listening for X11 forwarding. In the second terminal, you can now use Docker to launch a Fiji GUI. For example:
132-
133-
` docker run -e DISPLAY=192.168.15.2:0 fiji/fiji`
145+
```shell
146+
docker run -e DISPLAY=192.168.15.2:0 fiji/fiji
147+
```
134148

135149
Where the IP address was what we found earlier with `ifconfig`.
136150

@@ -147,8 +161,9 @@ Once you have Fiji up and running, you will probably want to open some images.
147161
The best way to share data with Docker is to use volumes, as described in [this blog post](http://haven.nightlyart.com/fiji-is-now-available-on-docker-hub/).
148162

149163
For example, if your data is in `/Users/foo/data`, launching the Fiji image with:
150-
151-
` docker run -v /Users/foo/data:/fiji/data -e DISPLAY=192.168.15.2:0 fiji/fiji`
164+
```shell
165+
docker run -v /Users/foo/data:/fiji/data -e DISPLAY=192.168.15.2:0 fiji/fiji
166+
```
152167

153168
will create a `data` subdirectory in the Fiji installation, which you can then open images from as normal.
154169

0 commit comments

Comments
 (0)