docker

docker+redis:
Dockerfile

FROM centos:latest
MAINTAINER Absurd "[email protected]"

RUN yum -y update &&  yum -y install epel-release && yum -y install redis && yum -y install net-tools

# redis
ENTRYPOINT [ "/usr/bin/redis-server" ]
EXPOSE 6379

docker build -t absurd/rick-redis .

docker+java:
Dockerfile

FROM absurd/rick-redis:latest
MAINTAINER Absurd "[email protected]"
ENV REFRESHED_AT 2017-06-06

# Install curl wget
#RUN yum -y install curl
#RUN yum -y install wget

# install jdk8
RUN cd /tmp
# &&  curl -L 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz' -H 'Cookie: oraclelicense=accept-securebackup-cookie; gpw_e24=Dockerfile' | tar -xz
ADD docker/jdk-8u131-linux-x64.tar.gz /tmp/
RUN mkdir -p /usr/lib/jvm
RUN mv /tmp/jdk1.8.0_131/ /usr/lib/jvm/jdk8/
# Set Oracle JDK 7 as default Java
RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk8/bin/java 300
RUN update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk8/bin/javac 300

# maven
RUN mkdir /var/tmp/maven
#RUN wget -P /var/tmp/maven  http://apache.fayea.com/maven/maven-3/3.3.9/binaries/jdk-8u131-linux-x64.tar.gz
#RUN tar xzf /var/tmp/maven/apache-maven-3.3.9-bin.tar.gz -C /var/tmp/maven
#RUN rm -rf /var/tmp/maven/apache-maven-3.3.9-bin.tar.gz
ADD docker/apache-maven-3.5.0-bin.tar.gz /var/tmp/maven/
ADD docker/settings.xml ~/.m2/settings.xml

ENV JAVA_HOME /usr/lib/jvm/jdk8/
ENV M2_HOME /var/tmp/maven/apache-maven-3.5.0
ENV PATH $PATH:$JAVA_HOME/bin:$M2_HOME/bin

jdk-8u131-linux-x64.tar.gz/jdk-8u131-linux-x64.tar.gz/settings.xml
都放在docker目录下,因为我网比较卡

docker build -t absurd/rick-java-redis .

微服务:

FROM absurd/rick-java-redis:latest
MAINTAINER Absurd "[email protected]"
ENV REFRESHED_AT 2017-06-06
WORKDIR /code

ADD target /code/target

#RUN ["mvn", "package","-Dmaven.test.skip=true"]

ENTRYPOINT ["java", "-jar", "target/rick-1.0-SNAPSHOT.jar"]

EXPOSE 8080

docker build -t absurd/rick-app .
docker run -ti
-p 8080:8080
--name rick_app
absurd/rick-app:latest \

你可能感兴趣的:(docker)