-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile
45 lines (33 loc) · 1.19 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM alpine:3.6
MAINTAINER Chu-Siang Lai <chusiang@drx.tw>
# Update the index of available packages.
RUN apk update
# Install the requires package.
RUN apk add --no-cache openssh python sudo curl wget bash bash-completion
# Setting the sshd.
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# Generate the ssh host keys.
RUN ssh-keygen -A
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# Create a new user.
#
# - username: docker
# - password: docker
RUN adduser -s /bin/bash -D docker && \
echo 'docker:docker' | chpasswd
# Add sudo permission.
RUN echo 'docker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Setting ssh public key.
RUN wget https://raw.githubusercontent.com/chusiang/ansible-jupyter.dockerfile/master/files/ssh/id_rsa.pub \
-O /tmp/authorized_keys && \
mkdir /home/docker/.ssh && \
mv /tmp/authorized_keys /home/docker/.ssh/ && \
chown -R docker:docker /home/docker/.ssh/ && \
chmod 644 /home/docker/.ssh/authorized_keys && \
chmod 700 /home/docker/.ssh
EXPOSE 22
# Run ssh server daemon.
CMD ["/usr/sbin/sshd", "-D"]