For Ansible practice, I wrote this because I wanted an image that can be entered by SSH.
Click here for CentOS7 Click here for CentOS6
Reference Docker 初心者 — ssh で接続できるサーバーを立てる
$ docker build -t ssh_ubuntu14:latest . --no-cache
$ docker run -d -p 2222:22 ssh_ubuntu14:latest
$ ssh-keygen -R [localhost]:2222
$ ssh -p 2222 kabigon@localhost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
RUN apt-get update && apt-get install -y openssh-server | |
RUN mkdir /var/run/sshd | |
RUN echo 'root:password' | chpasswd | |
# ユーザー作成 | |
RUN useradd kabigon | |
RUN echo 'kabigon:password' |chpasswd | |
RUN echo "kabigon ALL=(ALL) ALL" >> /etc/sudoers | |
RUN mkdir /home/kabigon | |
ENV NOTVISIBLE "in users profile" | |
RUN echo "export VISIBLE=now" >> /etc/profile | |
EXPOSE 22 | |
CMD ["/usr/sbin/sshd", "-D"] |