Skip to content

Commit e5852df

Browse files
author
amo
committed
Added section on extending docker image to use editors
1 parent ca9c246 commit e5852df

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

images.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in these docker images.
1919

2020
As the images have no editor installed by default you can create a simple
2121
program using `cat` as below. If needed you can install an editor with `apt-get`
22-
or by extending the docker image.
22+
or [by extending the docker image](#extending-the-docker-image).
2323

2424
Create a `hello.c`
2525

@@ -60,6 +60,8 @@ Create the `hello.c` file as described above, then to compile our program run
6060
or1k-elf-gcc hello.c -o hello
6161
```
6262

63+
If you see errors related to missing dependencies while compiling, you can add the dependent libraries [by extending the docker image](#extending-the-docker-image)
64+
6365
After the program is compiled we can run the program in the simulator with the
6466
following:
6567

@@ -226,6 +228,54 @@ Hello
226228
src/mor1kx_5.2/bench/verilog/mor1kx_monitor.v:140: $finish called at 171635 (1s)
227229
```
228230

231+
## Extending the docker image
232+
233+
To add vim or other terminal based text editors while running docker you can extend the docker image with the following steps:
234+
235+
1. Create a file named `Dockerfile` where you're planning to run OpenRISC image from (ensure you're not running the docker image):
236+
237+
```bash
238+
touch Dockerfile
239+
```
240+
241+
2. Add the following to the `Dockerfile` and save it:
242+
243+
```bash
244+
FROM stffrdhrn/or1k-sim-env
245+
246+
# Install the terminal-based Vim
247+
RUN apt-get update && apt-get install -y \
248+
vim \
249+
&& rm -rf /var/lib/apt/lists/*
250+
```
251+
252+
3. Build and run:
253+
254+
```bash
255+
docker build -t openrisc-vim .
256+
docker run -it openrisc-vim /bin/bash
257+
```
258+
259+
4. You should now be able to open and edit files using vim every time you run the above command:
260+
261+
```bash
262+
$ vi hello.c
263+
```
264+
265+
5. In case you see missing dependent libraries while going through this tutorial (especially while compiling with `gcc` if you see libmpc3, libmpfr6, libgmp10 libraries missing), you can add these to the Dockerfile and compile without errors:
266+
267+
```bash
268+
FROM stffrdhrn/or1k-sim-env
269+
270+
# Install the terminal-based Vim & other dependent lib
271+
RUN apt-get update && apt-get install -y \
272+
libmpc3 \
273+
libmpfr6 \
274+
libgmp10 \
275+
vim \
276+
&& rm -rf /var/lib/apt/lists/*
277+
```
278+
229279
## Further Reading
230280

231281
- [stffrdhrn/or1k-docker-images](https://github.com/stffrdhrn/or1k-docker-images) - OpenRISC docker images home page

0 commit comments

Comments
 (0)