Skip to content

Instantly share code, notes, and snippets.

@cive
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save cive/dd9a63cc90b09089e0c0 to your computer and use it in GitHub Desktop.

Select an option

Save cive/dd9a63cc90b09089e0c0 to your computer and use it in GitHub Desktop.

TODO

  • jenkins
  • EXPOSE 9000, 9999
  • git clone play-work
  • mysql server

書き方

公式では

RUN \
  do-something1
  do-something2

のような書き方が許されていたが,実際はうまくいかなかった.

起動からSSHログインまで

bash$ docker build -t hogehoge .
bash$ CONTAINER_ID=$(docker run -P -d hogehoge)
bash$ SSH_PORT=$(docker port $CONTAINER_ID 22 | cut -d: -f2)
bash$ SSH_HOST=$(docker port $CONTAINER_ID 22 | cut -d: -f1)
bash$ ssh -p $SSH_PORT docker@$SSH_HOST

もしくは(boot2dockerのパスを通していれば)

bash$ docker build -t hogehoge .
bash$ docker run -p 2222:22 hogehoge
bash$ ssh -p 2222 docker@$(boot2docker ip)

終了するときは

bash$ docker ps -a
bash$ docker stop DOCKER_NAME

参考文献

なぜかここにメモ

  • wget -O hogehoge URL <=> hogehogeと保存される
# dockerFile
# 2015/2/25
# CentOS Server
# playframework2.x (oracle java8, scala)
# CentOS version 6
FROM centos:centos6
MAINTAINER cive <hukurou55.1@gmail.com>
WORKDIR /data
RUN yum update -y
# initscripts => ランレベルの変更やネットワークの活性化/非活性化、システムシャットダウンやシステムブートの為の基本的なシステムスクリプト
# MAKEDEV => deviceファイルの作成
RUN yum -y install initscripts MAKEDEV tar unzip
# OpenSSH
RUN yum -y install passwd openssh-server sudo
RUN sed -ri 's/^#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
RUN sed -ri 's/^UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
RUN /etc/init.d/sshd start
RUN echo 'root:rootpassword' | chpasswd
RUN useradd docker
RUN echo 'docker:dockerpass' | chpasswd
RUN echo "docker ALL=(ALL) ALL" >> /etc/sudoers.d/docker
# Java
RUN yum -y install wget
RUN wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.rpm
RUN rpm -Uvh jdk-8u31-linux-x64.rpm
RUN rm jdk-8u31-linux-x64.rpm
ENV JAVA_HOME /usr/java/jdk1.8.0_31
# Scala
ENV SCALA_VERSION 2.11.5
RUN wget http://downloads.typesafe.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz
RUN tar xzvf scala-${SCALA_VERSION}.tgz
RUN rm scala-${SCALA_VERSION}.tgz
RUN mv scala-${SCALA_VERSION} /usr/local/
RUN ln -s /usr/local/scala-${SCALA_VERSION} /usr/local/scala
ENV SCALA_HOME /usr/local/scala
ENV PATH ${PATH}:${SCALA_HOME}/bin
# sbt
ENV SBT_VERSION 0.13.7
RUN wget https://dl.bintray.com/sbt/native-packages/sbt/${SBT_VERSION}/sbt-${SBT_VERSION}.tgz
RUN tar xzvf sbt-${SBT_VERSION}.tgz
RUN rm sbt-${SBT_VERSION}.tgz
RUN mv sbt /usr/local/
ENV SBT_HOME /usr/local/sbt
ENV PATH ${PATH}:${SBT_HOME}/bin
# activator(playframework)
# playframework 2.3.8
ENV ACTIVATOR_VERSION 1.3.2
RUN wget http://downloads.typesafe.com/typesafe-activator/${ACTIVATOR_VERSION}/typesafe-activator-${ACTIVATOR_VERSION}-minimal.zip
RUN unzip typesafe-activator-${ACTIVATOR_VERSION}-minimal.zip
RUN rm typesafe-activator-${ACTIVATOR_VERSION}-minimal.zip
RUN mv activator-${ACTIVATOR_VERSION}-minimal /usr/local/activator
RUN ln -s /usr/local/activator-${ACTIVATOR_VERSION}-minimal /usr/local/activator
ENV ACTIVATOR_HOME /usr/local/activator
ENV PATH ${PATH}:${ACTIVATOR_HOME}
# PATH
RUN echo -e '\n# scala\nexport SCALA_HOME="/usr/local/scala"' >> /root/.bashrc
RUN echo -e '\n# scala\nexport PATH="/usr/local/scala/bin:$PATH"' >> /root/.bashrc
RUN echo -e '\n# sbt\nexport PATH="/usr/local/sbt/bin:$PATH"' >> /root/.bashrc
RUN echo -e '\n# play\nexport PATH="/usr/local/activator:$PATH"' >> /root/.bashrc
CMD ["bash"]
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment