> git clone https://gist.github.com/tarao/e3bfd803b646a7b7638c octave
> octave/build
> octave/run
-
-
Save felipeluna/2404ebfa0f42997b43d8afa1ce966c12 to your computer and use it in GitHub Desktop.
Octave in a docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TAG="${DOCKER_TAG:-octave}" | |
DIR="$(cd $(dirname "$0"); pwd)" | |
docker build -t "$TAG" "$@" "$DIR" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:jessie | |
RUN apt-get update && apt-get install -yq less sudo octave && apt-get clean | |
COPY entrypoint.sh / | |
ENTRYPOINT [ "/entrypoint.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DOCKER_USER="${DOCKER_USER:-$(id -nu)}" | |
[ -n "$DOCKER_UID" ] && [ -n "$DOCKER_GID" ] && { | |
addgroup --gid "$DOCKER_GID" "$DOCKER_USER" | |
adduser --no-create-home --disabled-password --gecos "" \ | |
--uid "$DOCKER_UID" \ | |
--gid "$DOCKER_GID" \ | |
\ | |
"$DOCKER_USER" | |
} | |
sudo -u "$DOCKER_USER" DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" octave |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME="${DOCKER_NAME:-octave}" | |
TAG="${DOCKER_TAG:-octave}" | |
DOCKER_USER="$(id -nu)" | |
DOCKER_UID="$(id -ru)" | |
DOCKER_GID="$(id -rg)" | |
XSOCK=/tmp/.X11-unix | |
DISPLAY_HOST="$(echo "$DISPLAY" | cut -f 1 -d:)" | |
[ -n "$DISPLAY_HOST" ] && { | |
DISPLAY_NUMBER="$(echo "$DISPLAY" | cut -f 2 -d:)" | |
DISPLAY_IP="$(getent hosts "$DISPLAY_HOST" | tr -s '' '' | cut -f 1 -d ' ')" | |
DISPLAY="$DISPLAY_IP:$DISPLAY_NUMBER" | |
} | |
docker run -ti --rm --name "$NAME" \ | |
-e "DOCKER_USER=$DOCKER_USER" \ | |
-e "DOCKER_UID=$DOCKER_UID" \ | |
-e "DOCKER_GID=$DOCKER_GID" \ | |
-v /home:/home \ | |
-v "$XSOCK:$XSOCK" \ | |
-e "DISPLAY=$DISPLAY" \ | |
"$@" \ | |
"$TAG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment