Skip to content
Advertisement

Explanation of this docker file?

I am trying to understand this docker file

FROM ubuntu:trusty
MAINTAINER Wurstmeister 
RUN apt-get update; apt-get install -y unzip openjdk-7-jre-headless wget supervisor docker.io openssh-server
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64/
RUN echo 'root:wurstmeister' | chpasswd
RUN mkdir /var/run/sshd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

EXPOSE 22

I understood most of the lines but I don’t understand what these below lines means?

apt-get install -y unzip openjdk-7-jre-headless wget supervisor docker.io openssh-server
echo 'root:wurstmeister' | chpasswd
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

Can anyone help me understand? I am not sure what is the purpose of wget supervisor docker.io openssh-server in that line. Also what does echo mean there? And then also last sed line.

Advertisement

Answer

apt-get install -y unzip openjdk-7-jre-headless wget supervisor docker.io openssh-server

Installs a bunch of packages using the ubuntu package manager (the base image is Ubuntu Trusty 14.04).

The -y option is used to prevent apt from asking user confirmation about installing the packages and their dependencies: the installation just proceeds without need for any input. This is needed to avoid hanging the process of building the docker image. Packages installed:

  • openssh-server: so that the container can act as an ssh server and process requests from ssh clients
  • wget, unzip: utilities
  • java: eventually this container is used to allow users to access it via ssh, maybe those users need java
  • supervisor, docker.io: I don’t see a direct usage of it in the Dockerfile itself

then

echo 'root:wurstmeister' | chpasswd

Changes password of user root to wurstmeister

sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

Replaces the text PermitRootLogin without-password with PermitRootLogin yes in file /etc/ssh/sshd_config to allow root user to login with password or without (e.g., with public key).

An important general note: If you run SSHD in your Docker containers, you’re doing it wrong!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement