ubuntu14+java8的docker环境构建

安装docker

apt-get install curl
curl -sSL https://get.docker.com/ | sh

pull一个ubuntu的镜像

sudo docker pull ubuntu:14.04

启动并运行该镜像

sudo docker run -it --name usshd ubuntu:14.04 /bin/bash

安装sshd

sudo apt-get update && apt-get install -y openssh-server
sudo mkdir -p /var/run/sshd
sudo echo 'root:root' | chpasswd#修改root登录密码
sudo sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
sudo echo "export VISIBLE=now" >> /etc/profile

vim

sudo apt-get install vim

telnet client

sudo apt-get install telnet

java8

sudo apt-get install software-properties-common 
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y oracle-java8-installer oracle-java8-set-default

环境变量配置

vim ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source ~/.bashrc
echo $JAVA_HOME

创建镜像

sudo docker commit usshd ubuntu/java8

这里的usshd是之前docker run/create时指定的--name

sudo docker images

你可能感兴趣的:(java8,docker)