Hits : 14063


Below is my Dockerfile for building an archlinux image with sshd


archlinux base image https://hub.docker.com/r/archlinux/base
you can find out how i built it, here: archlinux installation for docker

Dockerfile


vim Dockerfile


# sshd on archlinux
#
# VERSION               0.0.1

FROM	 archlinux:latest
MAINTAINER 	Evaggelos Balaskas <evaggelos _AT_ balaskas _DOT_ gr>

# Update the repositories
RUN	 pacman -Syy

# Install openssh
RUN	 pacman -S --noconfirm openssh

# Generate host keys
RUN  /usr/bin/ssh-keygen -A

# Add password to root user
RUN	 echo 'root:roottoor' | chpasswd

# Fix sshd
RUN  sed -i -e 's/^UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config

# Expose tcp port
EXPOSE	 22

# Run openssh daemon
CMD	 ["/usr/sbin/sshd", "-D"]


How to Build the docker image


# docker build -t archlinux:sshd .

How to run the docker image


# docker run -d -p 2222:22 archlinux:sshd

How to connect to the docker image


[~]> ssh localhost -p 2222 -l root 

The authenticity of host '[localhost]:2222 ([::1]:2222)' can't be established.
ECDSA key fingerprint is 82:47:98:3a:2c:e2:d7:6f:9d:22:ba:ab:a9:0f:c8:d2.
Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '[localhost]:2222' (ECDSA) to the list of known hosts.

root@localhost's password: 

[root@6a942f29890a ~]# uptime
 20:02:04 up 6 days, 22:28,  0 users,  load average: 1.02, 0.89, 0.84