æ¦è¦
Oracle 社ã®å
¬å¼ã® Docker ã®è¨å®ãã¡ã¤ã«ã Github ä¸ã§å
¬éããã¦ãã¾ãã
github.com
è¨å®ãã¡ã¤ã«ã«ã¯æ§ã ãªè£½åã®ç©ãå«ã¾ãã¦ãã¾ãããä»åã¯ããã使ç¨ã㦠Oracle Java ã®å®è¡ç°å¢ãæ§ç¯ãã¾ãã
ä½æ¥
è¨å®ãã¡ã¤ã«ã¨ Java ã®ãµã¼ãã©ã³ã¿ã¤ã ããã¦ã³ãã¼ããã¾ãã次ã«ãµã¼ãã©ã³ã¿ã¤ã ãé©åãªç®æã«ç§»åãã¦ãDocker ã¤ã¡ã¼ã¸ãä½æãã¾ããæå¾ã«ä½æããã¤ã¡ã¼ã¸ã§ Java ã使ããã確èªãã¾ãã
Github ãã docker-images ãè½ã¨ãã¾ããgit ã³ãã³ãã§ãè¯ãã§ããããã©ã¦ã¶ããZIPãã¡ã¤ã«ããã¦ã³ãã¼ããåºæ¥ã¾ããdocker-images ã®ãã£ã¬ã¯ããªã移è¡ã¯ IMAGES_HOME ã¨ãã¾ãã
Java ã®ãµã¼ãã©ã³ã¿ã¤ã ã次ã®ãªã³ã¯ãããã¦ã³ãã¼ããã¾ãã
http://www.oracle.com/technetwork/java/javase/downloads/index.htmlwww.oracle.com
ãµã¼ãã©ã³ã¿ã¤ã 㯠Server JRE ã§ãããã¼ã¸ã§ã³ã¯ä»æ¥æç¹ã§ã®ææ°çã§ãã 8 update 112ããã©ãããã©ã¼ã 㯠Linux x64 ããã¦ã³ãã¼ããã¾ãããã¦ã³ãã¼ãããããã¡ã¤ã«å㯠server-jre-8u112-linux-x64.tar.gz ã¨ãªãã¾ãã
ãã¦ã³ãã¼ããããã¡ã¤ã«ã $IMAGES_HOME/OracleJava/java-8 ã¸ç§»åãã¾ãã
ããã¾ã§ã®ä½æ¥ã§æºåå®äºã§ãã$IMAGES_HOME/OracleJava/java-8 ã¸ç§»åã㦠OracleJavaã®ã¤ã¡ã¼ã¸ãä½æããã·ã§ã«ãå®è¡ãã¾ãã
$ ./build.sh
Sending build context to Docker daemon 59.91 MB Step 1 : FROM oraclelinux:latest latest: Pulling from library/oraclelinux 0c333d7e75d2: Pull complete Digest: sha256:f6cc386e1cc9d6702a67a3be885ddb70a30b0cdafc13d239f5b9ae55f76488ca Status: Downloaded newer image for oraclelinux:latest ---> 4ee18f43f945 Step 2 : MAINTAINER Bruno Borges <[email protected]> ---> Running in d72c4a866da2 ---> 73e2c75dddd2 Removing intermediate container d72c4a866da2 Step 3 : ENV JAVA_PKG server-jre-8u*-linux-x64.tar.gz JAVA_HOME /usr/java/default ---> Running in 4f877a4c9d01 ---> 9362ed2dcc29 Removing intermediate container 4f877a4c9d01 Step 4 : ADD $JAVA_PKG /usr/java/ ---> 3a6dd166fd2f Removing intermediate container 5c3979416bc7 Step 5 : RUN export JAVA_DIR=$(ls -1 -d /usr/java/*) && ln -s $JAVA_DIR /usr/java/latest && ln -s $JAVA_DIR /usr/java/default && alternatives --install /usr/bin/java java $JAVA_DIR/bin/java 20000 && alternatives --install /usr/bin/javac javac $JAVA_DIR/bin/javac 20000 && alternatives --install /usr/bin/jar jar $JAVA_DIR/bin/jar 20000 ---> Running in eccc46eebc49 ---> baadd9279b4b Removing intermediate container eccc46eebc49 Successfully built baadd9279b4b
Successfully ã¨åºãã°æ§ç¯å®äºã§ãã次ã¯æ§ç¯ããã Java ã試ãããã« Java ã®ãã¼ã¸ã§ã³ã確èªããã¤ã¡ã¼ã¸ãä½æãã¾ããDockerfile ã¯æ¬¡ã®éãã§ããjava-8 ã®ãã£ã¬ã¯ããªã«ã¯æ¢ã« Dockerfile ãããããå¥ã®ãã£ã¬ã¯ããªã«ç§»åãã¦ãã Dockerfile ãä½ãã¾ãããã
$ vim Dockerfile
FROM oracle/serverjre:8 CMD ["java","-version"]
ãã«ãã㦠Docker ã¤ã¡ã¼ã¸ãä½æãããå®è¡ãã¦ã¿ã¾ã
$ docker build -t jversion .
Sending build context to Docker daemon 4.096 kB Step 1 : FROM oracle/serverjre:8 ---> baadd9279b4b Step 2 : CMD java -version ---> Running in 08ab54ae95b0 ---> c50444f69864 Removing intermediate container 08ab54ae95b0 Successfully built c50444f69864
$ docker run -i jversion
java version "1.8.0_112" Java(TM) SE Runtime Environment (build 1.8.0_112-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
ãã¦ã³ãã¼ããããã¼ã¸ã§ã³çªå·ãåºåããã¦ããã°ç¢ºèªå®äºã§ãã次åã¯ãå®éã«ç°¡åãªã¢ããªã±ã¼ã·ã§ã³ãæ¸ãã¦åããã¦ã¿ã¾ãã