8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Play with Docker で SSHした時のメモ

Last updated at Posted at 2019-10-17

image.png

Play with Docker でsshしたい

クラウドでDockerを試せるPlay with DockerでSSHしたい!ということでやってみました。
Play with Docker Doc

とりあえずやってみる

コンソール画面に「ssh ip172-18-0-5-bmju42udo98g00af0qvg@direct.labs.play-with-docker.com」と、SSH用のコマンドがあるのでコレを叩けばつながるだろうと思い叩いてみます。

image.png

叩いてみる
$ ssh ip172-18-0-5-bmju42udo98g00af0qvg@direct.labs.play-with-docker.com
The authenticity of host 'direct.labs.play-with-docker.com (40.76.55.146)' can't be established.
RSA key fingerprint is SHA256:ABCDefghIjk12345677890Adfe32deafd .
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'direct.labs.play-with-docker.com,40.76.55.146' (RSA) to the list of known hosts.
ip172-18-0-5-bmju42udo98g00af0qvg@direct.labs.play-with-docker.com: Permission denied (publickey).

「Permission denied (publickey).」と出力され上手くいきません...

以下、同様の記事発見。
PWDインスタンス #285 にSSH接続できません

「公開鍵がないよ!」ってことみたいです。
ということで公開鍵作ります。

ssh-keygenする
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxxxxxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/xxxxxxxx/.ssh/id_rsa.
Your public key has been saved in /c/Users/xxxxxxxx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:kp2qcIE/ABCDefghIjk12345677890Adfe32deafd xxxxxxxx@xxxxxx
The key's randomart image is:

+---[RSA 2048]----+
|. .              |
|o= o=            |
|O = +o           |
|+B.@ + o .       |
|=oB.@ + S        |
|++.B = oo        |
|ooE.B .          |
|o...B o          |
|    .            |
+----[SHA256]-----+

公開鍵作ったので、再度SSHしていきます!

再度SSH接続!
$ ssh ip172-18-0-5-bmju42udo98g00af0qvg@direct.labs.play-with-docker.com
Connecting to 40.117.153.174:8022
###############################################################
#                          WARNING!!!!                        #
# This is a sandbox environment. Using personal credentials   #
# is HIGHLY! discouraged. Any consequences of doing so are    #
# completely the user's responsibilites.                      #
#                                                             #
# The PWD team.                                               #
###############################################################
[node1] (local) root@192.168.0.18 ~

上手くいきました!

せっかくなので...

せっかくなので、PWDでReactを立ち上げてみようと思います。
dockerhu nodeより、nodeのdockerを取得、Reactをインストールして立ち上げます。

$ docker run -it --name node -p 3000:3000 node:10.16.3-alpine /bin/sh
# cd opt
# npx create-react-app my-app
# cd my-app
# npm start

Reactを立ち上げたので、ブラウザから接続していきます。
接続先は「3000」のリンクよりいけるみたいです。
(http://ip172-18-0-5-bmju42udo98g00af0qvg-3000.direct.labs.play-with-docker.com/)

image.png
image.png

Reactの画面が表示されました!
自分のマシンを使わず汚さずパパっとDockerを試せる「Play with Docker」便利ですね!

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?