Skip to content

Instantly share code, notes, and snippets.

@Wei1234c
Last active September 4, 2015 17:18
Show Gist options
  • Save Wei1234c/320538a688d8caa8a4a3 to your computer and use it in GitHub Desktop.
Save Wei1234c/320538a688d8caa8a4a3 to your computer and use it in GitHub Desktop.
Oracle Java8 sshd root-login
# Oracle java8_sshd_root-login dockerfile for armv7
# Ref 1: https://github.com/dockerfile/java/tree/master/oracle-java8
# Ref 2: https://docs.docker.com/examples/running_ssh_service/
#
# by: Wei Lin
# date: 2015/9/4
# Pull base image.
FROM armv7/armhf-ubuntu:14.04
MAINTAINER Wei Lin
# export TERM=linux
ENV TERM linux
# Identity for excuting the script.
# sudo su
# USER root
# Install Java _______________________________________________________________________________________________
RUN \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
apt-get remove -y software-properties-common && \
rm -rf /var/cache/oracle-jdk8-installer
# Define commonly used JAVA_HOME variable.
# export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
ENV JAVA_HOME "/usr/lib/jvm/java-8-oracle"
# Append PATH
# export PATH=${PATH}:${JAVA_HOME}/bin
# echo ${PATH}
# read -rsp $'Press any key or wait 15 seconds to continue...\n' -n 1 -t 15
ENV PATH ${PATH}:${JAVA_HOME}/bin
# Install SSH ________________________________________________________________________________________________
RUN \
apt-get install -y openssh-server && \
mkdir /var/run/sshd
# root password and login permission
# Please set root's password as you like
RUN \
echo 'root:hadoop' | chpasswd && \
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# Add user pi
# Please set pi's password as you like, or just comment out this.
RUN \
useradd -G adm,sudo,users -s /bin/bash -m pi && \
echo 'pi:raspberry' | chpasswd
# SSH login fix. Otherwise user is kicked off after login
RUN \
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
# Expose port 22
EXPOSE 22
# Define default command.
CMD ["/usr/sbin/sshd", "-D"]
# Misc. ______________________________________________________________________________________________________
# Set time zone
RUN \
echo "Asia/Taipei" > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata
# Environment variables
RUN \
echo " " >> /etc/bash.bashrc && \
echo "#_____________________" >> /etc/bash.bashrc && \
echo "force_color_prompt=yes" >> /etc/bash.bashrc && \
echo "alias cls='clear'" >> /etc/bash.bashrc && \
echo "export TERM=linux" >> /etc/bash.bashrc
# Upgrade and clean up
RUN \
apt-get dist-upgrade -y && \
apt-get autoremove -y && \
apt-get autoclean -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment