docker: Add interactive sessions

Provide a nice interface when using the container interactively.
This commit is contained in:
Andre Richter 2017-09-02 22:17:17 +02:00
parent 6e3c76ea23
commit 114de48b20
No known key found for this signature in database
GPG key ID: 2116C1AB102F615E
4 changed files with 19 additions and 3 deletions

3
docker/.bash_aliases Normal file
View file

@ -0,0 +1,3 @@
# Hijack this file to set this PS1, visually indicating to the user that we are running the docker container
PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[1;35m\]<$IMAGE_NAME>\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "

View file

@ -1,5 +1,7 @@
FROM rustlang/rust:nightly FROM rustlang/rust:nightly
ENV IMAGE_NAME=redox-os-docker
RUN set -ex; \ RUN set -ex; \
apt-get update; \ apt-get update; \
apt-get install -q -y --no-install-recommends \ apt-get install -q -y --no-install-recommends \
@ -30,8 +32,8 @@ RUN set -ex; \
apt-get clean -q -y; \ apt-get clean -q -y; \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /usr/local/bin/entrypoint.sh COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh COPY .bash_aliases /etc/skel/
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["bash", "/usr/local/bin/entrypoint.sh"]
CMD ["/bin/bash"] CMD ["/bin/bash"]

View file

@ -52,6 +52,17 @@ docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse \
-v redox-"$(id -u)-$(id -g)"-rustup:/usr/local/rustup \ -v redox-"$(id -u)-$(id -g)"-rustup:/usr/local/rustup \
-v "$(pwd):$(pwd)" -w "$(pwd)" --rm redox make fetch all -v "$(pwd):$(pwd)" -w "$(pwd)" --rm redox make fetch all
``` ```
### Run the container interactively
```shell
docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse \
-e LOCAL_UID="$(id -u)" -e LOCAL_GID="$(id -g)" \
-v redox-"$(id -u)-$(id -g)"-cargo:/usr/local/cargo \
-v redox-"$(id -u)-$(id -g)"-rustup:/usr/local/rustup \
-v "$(pwd):$(pwd)" -w "$(pwd)" --rm -it redox
```
#### Demo
![Image of Usage](interactive_demo.gif)
### Clear the named volume containing the cargo cache ### Clear the named volume containing the cargo cache
```shell ```shell

BIN
docker/interactive_demo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 KiB