Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saccadic/749dda5e1cf882f3032462b2faff2f85 to your computer and use it in GitHub Desktop.
Save saccadic/749dda5e1cf882f3032462b2faff2f85 to your computer and use it in GitHub Desktop.
#Ubuntu in docker
---
```bash
#Dockerfile
FROM ubuntu:16.04 #<-好きなバージョン
RUN apt-get update
RUN apt-get install -y openssh-server nano
RUN mkdir /var/run/sshd
RUN echo 'root:root' |chpasswd
RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
```
---
##注意点
* [~]->自分で設定したパラメータに置き換える.[]はいらない
---
##手順:Docker
1. cd Dockerfileがある場所へ
2. docker build -t 自分の名前/Liunxの名前:バージョン番号 ./
* イメージを作成
3. docker run -d -P --name test_sshd [コンテナIDor名前]
* コンテナ作成
4. docker ps
* 22ポートへ変換するLocalhostのポート番号を確認
---
##手順:SSH
1. ssh接続開始
2. ssh [ログインID]@localhost -p [確認したポート番号]
* ログインID:root
* ログインPW:root
---
参考
* [rastasheep/ubuntu-sshd](https://hub.docker.com/r/rastasheep/ubuntu-sshd/)
* [コマンド集](http://paiza.hatenablog.com/entry/docker_intro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment