Notes and Talks/UJEP/UPC/01/docker

Simple docker container

docker-compose.ymlservices:
  upc:
    build: .
    container_name: upc
    stdin_open: true
    tty: true
    volumes:
      - ./src:/src
DockerfileFROM debian:stable-slim

# terminal prompt, aliases
RUN cat >> /root/.bashrc << EOT
PS1='\[\033[01;33m\]$\[\033[01;32m\]\W\[\033[00m\] '
alias ls='ls --color=auto'
alias ll='ls -l --color=auto'
EOT

# install C compiler and tools
RUN apt-get update && apt-get install -y \
    make gcc binutils gdb gdbserver \
    libcomerr2 mc vim nano less \
    valgrind libncurses-dev

WORKDIR /src

# keep container running
CMD ["/bin/bash"]
bash.sh#!/bin/bash
# open bash shell in the container

CONTAINER="upc"

echo $CONTAINER "..."
docker exec -it $CONTAINER /bin/bash
echo "..." $CONTAINER

Download the files: c-docker.zip

Work inside the container

ed

is the original line-based editor.
Example session:

bashapt install ed # install the editor
bash$ ed notes.txt
a
First line
Second line
.
w
q
$ cat notes.txt
bashed notes.txt
0a
0000
.
3i
3333
.
w
q
$ cat notes.txt
bash$ ed notes.txt
1,$p
2c
Replacement text
.
4d
w
q
$ cat notes.txt

`vi (vim)

is a full-screen editor.
Example session:

bash$ vi notes.txt
# i  insert mode
# Esc  exit insert mode
# :w  save
# :q  quit
# :wq  save and quit (or ZZ)
# :q!  quit without saving

nano

is a simple, user-friendly text editor.
Example session:

bash$ nano notes.txt