You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/tutorials/development_containers1/index.md
+12-10
Original file line number
Diff line number
Diff line change
@@ -138,7 +138,7 @@ Either way, note that you need to run the docker app or docker in a terminal *as
138
138
More info about the installation on your specific Linux operation systems [can be found here](https://docs.docker.com/engine/install).
139
139
The procedure for Debian or Ubuntu-based distributions involves trusting dockers gpg keys and adding an extra repository, [some caution is warranted](https://wiki.debian.org/DontBreakDebian).
# sudo pacman -Sy docker docker-buildx # Arch Linux
@@ -151,7 +151,7 @@ Many features which you would take for granted in this kind of software (securit
151
151
For users to be able to use Docker, they must be in the "docker" group.
152
152
(Insert your username at `<your-username>`.)
153
153
154
-
```{sh}
154
+
```sh
155
155
#| eval: false
156
156
sudo usermod -a -G docker <your-username>
157
157
```
@@ -165,7 +165,7 @@ However, due to [diverse](https://docs.docker.com/engine/security) [security](ht
165
165
166
166
On a `systemd` system, you can start and stop Docker on demand via the following commands (those will ask you for `sudo` authentification if necessary).
167
167
168
-
```{sh}
168
+
```sh
169
169
#| eval: false
170
170
systemctl start docker
171
171
@@ -179,7 +179,7 @@ For aficionados: docker actually runs multiple services: the docker service, the
179
179
180
180
You can check the Docker installation by confirming the version at which the service is running.
181
181
182
-
```{sh}
182
+
```sh
183
183
#| eval: false
184
184
docker --version
185
185
```
@@ -296,14 +296,16 @@ In this (and only this) situation, the simple solution is to copy a clone of the
296
296
The `git clone` should reside within the Dockerfile folder.
297
297
Then the Dockerfile section can look like the following:
298
298
299
-
# copy the repo
300
-
COPY my_private_repo /opt/my_private_repo
299
+
```
300
+
# copy the repo
301
+
COPY my_private_repo /opt/my_private_repo
301
302
302
-
# manually install dependencies
303
-
RUN R -q -e 'install.packages("remotes", dependencies = TRUE)'
303
+
# manually install dependencies
304
+
RUN R -q -e 'install.packages("remotes", dependencies = TRUE)'
304
305
305
-
# install package from folder
306
-
RUN R -q -e 'install.packages("/opt/my_private_repo", repos = NULL, type = "source", dependencies = TRUE)'
306
+
# install package from folder
307
+
RUN R -q -e 'install.packages("/opt/my_private_repo", repos = NULL, type = "source", dependencies = TRUE)'
308
+
```
307
309
308
310
This way of handling private repositories [seems to be good practice](https://stackoverflow.com/questions/23391839/clone-private-git-repo-with-dockerfile/55761914#55761914), for being simple, secure, and generally most feasible.
Copy file name to clipboardExpand all lines: content/tutorials/development_containers1/index.qmd
+5-5
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ Either way, note that you need to run the docker app or docker in a terminal *as
147
147
More info about the installation on your specific Linux operation systems [can be found here](https://docs.docker.com/engine/install).
148
148
The procedure for Debian or Ubuntu-based distributions involves trusting dockers gpg keys and adding an extra repository, [some caution is warranted](https://wiki.debian.org/DontBreakDebian).
# sudo pacman -Sy docker docker-buildx # Arch Linux
@@ -162,7 +162,7 @@ Many features which you would take for granted in this kind of software (securit
162
162
For users to be able to use Docker, they must be in the "docker" group.
163
163
(Insert your username at `<your-username>`.)
164
164
165
-
```{sh}
165
+
```sh
166
166
#| eval: false
167
167
sudo usermod -a -G docker <your-username>
168
168
```
@@ -178,7 +178,7 @@ However, due to [diverse](https://docs.docker.com/engine/security) [security](ht
178
178
179
179
On a `systemd` system, you can start and stop Docker on demand via the following commands (those will ask you for `sudo` authentification if necessary).
180
180
181
-
```{sh}
181
+
```sh
182
182
#| eval: false
183
183
systemctl start docker
184
184
@@ -195,7 +195,7 @@ For aficionados: docker actually runs multiple services: the docker service, the
195
195
196
196
You can check the Docker installation by confirming the version at which the service is running.
197
197
198
-
```{sh}
198
+
```sh
199
199
#| eval: false
200
200
docker --version
201
201
```
@@ -328,7 +328,7 @@ In this (and only this) situation, the simple solution is to copy a clone of the
328
328
The `git clone` should reside within the Dockerfile folder.
329
329
Then the Dockerfile section can look like the following:
Note that the following `hello.py` file needs to be present in your working directory (you will be reminded by a friendly error message):
123
125
@@ -132,7 +134,7 @@ def hello():
132
134
133
135
With the `Dockerfile` and `hello.py` in place, you can build the container [^2].
134
136
135
-
```{sh}
137
+
```sh
136
138
#| eval: false
137
139
# on Windows, you are already in an administrator terminal
138
140
docker build --pull -t my-flask .
@@ -156,7 +158,7 @@ You should now see a `python` image, which is the base alpine image we built upo
156
158
There is also a `my-flask`.
157
159
Try it!
158
160
159
-
```{sh}
161
+
```sh
160
162
#| eval: false
161
163
docker run my-flask
162
164
```
@@ -208,36 +210,38 @@ They prepared quite [a lot of useful images](https://hub.docker.com/u/rocker), i
208
210
209
211
Note the syntax in `FROM`: it is `rocker/<image>:<version>`.
210
212
211
-
FROM rocker/rstudio:latest
212
-
# (Use the rocker rstudio image)
213
+
```
214
+
FROM rocker/rstudio:latest
215
+
# (Use the rocker rstudio image)
213
216
214
-
# update the system packages
215
-
RUN apt update \
216
-
&& apt upgrade --yes
217
+
# update the system packages
218
+
RUN apt update \
219
+
&& apt upgrade --yes
217
220
218
-
# git2rdata requires git
219
-
RUN apt-get update \
220
-
&& apt-get install -y --no-install-recommends \
221
-
git libgit2-dev\
222
-
&& apt-get clean
221
+
# git2rdata requires git
222
+
RUN apt-get update \
223
+
&& apt-get install -y --no-install-recommends \
224
+
git libgit2-dev\
225
+
&& apt-get clean
223
226
224
-
# update pre-installed R packages
225
-
# RUN Rscript -e 'update.packages(ask=FALSE)'
227
+
# update pre-installed R packages
228
+
# RUN Rscript -e 'update.packages(ask=FALSE)'
226
229
227
-
# copy a `.Rprofile` to the container
228
-
# available here: https://tutorials.inbo.be/installation/administrator/admin_install_r/Rprofile.site
229
-
COPY docker/.Rprofile $R_HOME/etc/Rprofile.site
230
+
# copy a `.Rprofile` to the container
231
+
# available here: https://tutorials.inbo.be/installation/administrator/admin_install_r/Rprofile.site
232
+
COPY docker/.Rprofile $R_HOME/etc/Rprofile.site
230
233
231
-
# install package via an R command (`R -q -e` or `Rscript -e`)
232
-
# (a) from pre-configured repositories
233
-
RUN Rscript -e 'install.packages("git2rdata")'
234
+
# install package via an R command (`R -q -e` or `Rscript -e`)
235
+
# (a) from pre-configured repositories
236
+
RUN Rscript -e 'install.packages("git2rdata")'
234
237
235
-
# (b) via r-universe
236
-
RUN R -q -e 'install.packages("watina", repos = c(inbo = "https://inbo.r-universe.dev", CRAN = "https://cloud.r-project.org"))'
238
+
# (b) via r-universe
239
+
RUN R -q -e 'install.packages("watina", repos = c(inbo = "https://inbo.r-universe.dev", CRAN = "https://cloud.r-project.org"))'
237
240
238
-
# (b) from github
239
-
RUN R -q -e 'install.packages("remotes")'
240
-
RUN R -q -e 'remotes::install_github("inbo/INBOmd", dependencies = TRUE)'
241
+
# (b) from github
242
+
RUN R -q -e 'install.packages("remotes")'
243
+
RUN R -q -e 'remotes::install_github("inbo/INBOmd", dependencies = TRUE)'
244
+
```
241
245
242
246
It takes some puzzle work to get the dependencies right, e.g. with the `libgit2` dependency (try commenting out that line to get a feeling for build failure).
243
247
However, there is hope: (i) the error output is quite instructive (at least for Linux users), (ii) building is incremental, so you can add successively.
@@ -255,14 +259,14 @@ More here: <https://docs.docker.com/build/building/best-practices>
255
259
256
260
Test the image:
257
261
258
-
```{sh}
262
+
```sh
259
263
#| eval: false
260
264
docker build -t test-rstudio .
261
265
```
262
266
263
267
Run it, as before:
264
268
265
-
```{sh}
269
+
```sh
266
270
#| eval: false
267
271
docker run --rm -p 8787:8787 -e PASSWORD=YOURNEWPASSWORD test-rstudio
We note some useful commands on the way: `podman system ...` and `podman info`.
113
113
You might immediately check "native rootless overlays" (has something to do with mounting filesystems in the container):
114
114
115
-
```{sh}
115
+
```sh
116
116
#| eval: false
117
117
podman info | grep -i overlay
118
118
```
@@ -127,7 +127,7 @@ You can use images from `docker.io` with Podman.
127
127
The only difference from Docker is the explicit mention of the source, `docker.io`.
128
128
For example:
129
129
130
-
```{sh}
130
+
```sh
131
131
#| eval: false
132
132
podman search docker.io/alpine
133
133
podman pull docker.io/alpine # download a machine
@@ -141,7 +141,7 @@ Except for the prefix, everything you [can read in our `docker run` tutorial](..
141
141
142
142
Note that at least some `docker.io` images will not work: I actually experienced issues with the "rootless Docker image":
143
143
144
-
```{sh}
144
+
```sh
145
145
#| eval: false
146
146
# podman run --rm -it docker.io/docker:25.0-dind-rootless
147
147
```
@@ -162,7 +162,7 @@ Any Dockerfile should work, with the mentioned mini-adjustment to `FROM`.
162
162
And you can use any Docker image; `docker.io/rocker/rstudio`[is available](https://rocker-project.org/use/rootless-podman.html) (don't forget to specify the port).
163
163
You may even write `docker` in the terminal: it will alias to `podman` (via the `podman-docker` package on Linux, or an alias).
164
164
165
-
```{sh}
165
+
```sh
166
166
#| eval: false
167
167
podman run --rm -p 8787:8787 -e PASSWORD=YOURNEWPASSWORD -v /data/git/coding-club:/root/coding-club docker.io/rocker/rstudio
0 commit comments