如何创建基于Alpine Linux的JRE环境

时间:2017-01-20 21:09:46   收藏:0   阅读:4970


  1. [root@localhost jre8]#  cat repositories

  2. http://nl.alpinelinux.org/alpine/v3.5/main

  3. http://nl.alpinelinux.org/alpine/v3.5/community


  1. FROM alpine:3.5

  2. MAINTAINER jre8.111

  3. ENV JAVA_HOME=/usr/lib/jvm/default-jvm/jre

  4. add repositories /etc/apk/repositories

  5. RUN apk upgrade --update-cache; \

  6.    apk add openjdk8-jre; \

  7.    rm -rf /tmp/* /var/cache/apk/*

  8. CMD ["java", "-version"]


  1. [root@localhost jre8]#  docker build -t 192.168.138.123/docker-jre:8u111_14r1 .


  1. [root@localhost jre8]# docker images

  2. REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE

  3. 192.168.138.123/docker-jre   8u111_14r1          abd8e22c1bb1        14 seconds ago      76.8 MB

  4. docker.io/alpine            3.5                 88e169ea8f46        3 weeks ago         3.98 MB

  5. docker.io/alpine            latest              88e169ea8f46        3 weeks ago         3.98 MB


  1. [root@localhost jre8]# docker run --name test -tid   abd8e22c1bb1  sh

  2. [root@localhost jre8]# docker-enter   test

  3. 3d876724639b:~# java -version

  4. openjdk version "1.8.0_111"

  5. OpenJDK Runtime Environment (IcedTea 3.2.0) (Alpine 8.111.14-r1)

  6. OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

  1. [root@10 ~]# vim /bin/docker-enter

  2. #!/bin/sh

  3. if [ -e $(dirname "$0")/nsenter ]; then

  4.        # with boot2docker, nsenter is not in the PATH but it is in the same folder

  5.        NSENTER=$(dirname "$0")/nsenter

  6. else

  7.        NSENTER=nsenter

  8. fi

  9. if [ -z "$1" ]; then

  10.        echo "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...]"

  11.        echo ""

  12.        echo "Enters the Docker CONTAINER and executes the specified COMMAND."

  13.        echo "If COMMAND is not specified, runs an interactive shell in CONTAINER."

  14. else

  15.        PID=$(docker inspect --format "{{.State.Pid}}" "$1")

  16.        if [ -z "$PID" ]; then

  17.          exit 1

  18.        fi

  19.        shift

  20.        OPTS="--target $PID --mount --uts --ipc --net --pid --"

  21.        if [ -z "$1" ]; then

  22.          "$NSENTER" $OPTS su - root

  23.        else

  24.          "$NSENTER" $OPTS env --ignore-environment -- "$@"

  25.        fi

  26. fi

  27. [root@10 ~]# chmod +x /bin/docker-enter

























本文出自 “纳米龙” 博客,请务必保留此出处http://arlen.blog.51cto.com/7175583/1893405

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!