支持jdk8、 sshd、 python3.6
构建后启动命令 docker run -it -d -p 10022:22 --name javapy 535704264/javapy:v1
ssh登陆, 密码 root ssh root@127.0.0.1 -p 10022
问题 1、ssh登陆, 环境变量设置无效
# Version: 1.0.0
# Description: 具有java、python、sshd 环境的ubuntu
FROM ubuntu:16.04
MAINTAINER Ni Dazhong
# 替换阿里源
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && cp /etc/apt/sources.list /etc/apt/sources.list.bak && cat /dev/null > /etc/apt/sources.list
RUN echo "deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted" >> /etc/apt/sources.list
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted" >> /etc/apt/sources.list
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial universe" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties" >> /etc/apt/sources.list
&& echo "deb http://archive.canonical.com/ubuntu xenial partner" >> /etc/apt/sources.list
&& echo "deb-src http://archive.canonical.com/ubuntu xenial partner" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted" >> /etc/apt/sources.list
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe" >> /etc/apt/sources.list
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse" >> /etc/apt/sources.list
# 支持ifconfig、 ping、 vim (debconf: delaying package configuration ... 警告可忽略)
RUN apt-get update && apt-get -y install net-tools iputils-ping vim curl wget
# 支持sshd
RUN apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:root' |chpasswd
RUN sed -ri 's/^#?PermitRootLogins+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
RUN mkdir /root/.ssh
# 安装java8
ADD jdk-8u181-linux-x64.tar.gz /usr/local/java
ENV JAVA_HOME /usr/local/java/jdk1.8.0_181
ENV CLASSPATH .:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH $PATH:$JAVA_HOME/bin
# 安装python3.6
WORKDIR /tmp
RUN mkdir -p /usr/local/python3.6
RUN apt install -y build-essential checkinstall
&& apt install -y libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
RUN wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz
RUN tar xvf Python-3.6.9.tar.xz && cd Python-3.6.9 && ./configure --prefix=/usr/local/python3.6 && make altinstall
# 建立软链接
RUN ln -snf /usr/local/python3.6/bin/python3.6 /usr/bin/python3 && ln -snf /usr/local/python3.6/bin/pip3.6 /usr/bin/pip3
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]