Last active
December 27, 2015 04:19
-
-
Save hagix9/7266124 to your computer and use it in GitHub Desktop.
Dockerfile Part1
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
#ディレクトリ作成、移動 | |
mkdir centos_ssh | |
cd centos_ssh | |
#コンテナイメージ作成ファイルの作成 | |
vi Dockerfile | |
#choice container image | |
FROM centos | |
#install package | |
RUN yum install -y passwd | |
RUN yum install -y openssh-server | |
RUN yum install -y openssh-clients | |
RUN yum install -y sudo | |
#RUN yum install -y vim | |
#RUN yum install -y telnet | |
#RUN yum install -y tcpdump | |
#RUN yum install -y ftp | |
RUN yum install -y httpd | |
#useradd settings | |
RUN useradd stack | |
RUN echo "stack" | passwd --stdin stack | |
RUN su - stack -c 'ssh-keygen -N "" -t rsa -f /home/stack/.ssh/id_rsa' | |
#sudo settings | |
RUN echo "stack ALL=(ALL) ALL" >> /etc/sudoers.d/stack | |
#sshd settings | |
RUN sed -i.bak 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config | |
#httpd settings | |
RUN chkconfig httpd on | |
#portforward settings | |
#EXPOSE 10022:22 | |
#EXPOSE 10080:80 | |
#EXPOSE 22 | |
#EXPOSE 80 | |
#init | |
CMD ["init"] | |
#ビルド | |
docker build -t "sshd/centos" . | |
#コンテナ起動 | |
docker run -t -i -d -p 11111:22 -p 22222:80 sshd/centos | |
#問題が合った場合のコンテナ起動 | |
#Dockerfileの CMD ["init"] をコメントしてビルドした後で | |
docker run -t -i -d -p 11111:22 -p 22222:80 sshd/centos /bin/bash | |
#などとして設定を確認 | |
#コンテナ削除 | |
for i in `sudo docker ps -a | awk '{print $1}' | grep -v ID`; do sudo docker rm $i; done | |
#コンテナ起動イメージ削除 | |
docker rmi sshd/centos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment