dockerでマウントする カレンダー連携⑥

· ☕ 2

朝、マウント(同期)が上手くいかなかったので、リベンジ

windowsのdockerでは/c/xxxを見ていて、

wslでは/c/xxxがマウントされた/mnt/c/xxxを見ている

なんか、この辺がよくないことになっているよう…。

前回までの流れはこちら

ただ、requirements.txtはdockerから見れているので、

wsl—>docker

wsl<-x-docker

ってこと…。

うーん…。

明示的にマウントする?

朝は↓をやってたけど、

$ docker run --rm docker-layers:1.0

とりあえず、マウントオプション付けてみる

-v ローカルディレクトリ:コンテナディレクトリ?

よく分からんのよね、この辺…。

誰かまじで、給料払うから教えてほしいww

で、とりあえず実行してみる

$ docker run --rm -v "$PWD"/test/:/var/task docker-layers:1.0
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

あーあ、testフォルダのrequirements.txt認識されなくなっちゃった…。

$ ls
Dockerfile  test

ちゃんあるか確認すると、ちゃんとあるw

$ echo $PWD
/mnt/c/github/runau/lineBot/docker

/mntだからいけないのかな…。

フルパス(/c/)指定

$ docker run --rm -v /c/github/runau/lineBot/docker/test:/var/task docker-layers:1.0
Collecting httplib2
  Downloading httplib2-0.17.0-py3-none-any.whl (95 kB)
Collecting oauth2client
  Downloading oauth2client-4.1.3-py2.py3-none-any.whl (98 kB)
Collecting google-api-python-client
  Downloading google-api-python-client-1.7.11.tar.gz (142 kB)
Collecting rsa>=3.1.4
  Downloading rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting six>=1.6.1
  Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting pyasn1>=0.1.7
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Collecting pyasn1-modules>=0.0.5
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting google-auth>=1.4.1
  Downloading google_auth-1.11.2-py2.py3-none-any.whl (76 kB)
Collecting google-auth-httplib2>=0.0.3
  Downloading google_auth_httplib2-0.0.3-py2.py3-none-any.whl (6.3 kB)
Collecting uritemplate<4dev,>=3.0.0
  Downloading uritemplate-3.0.1-py2.py3-none-any.whl (15 kB)
Collecting setuptools>=40.3.0
  Downloading setuptools-45.2.0-py3-none-any.whl (584 kB)
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.0.0-py3-none-any.whl (10 kB)
Building wheels for collected packages: google-api-python-client
  Building wheel for google-api-python-client (setup.py): started
  Building wheel for google-api-python-client (setup.py): finished with status 'done'
  Created wheel for google-api-python-client: filename=google_api_python_client-1.7.11-py3-none-any.whl size=56530 sha256=bab3a40c1bec240a47ca6cd09cef3bda865a0a6ea31d3d73e00d2f933c60b7ef
  Stored in directory: /root/.cache/pip/wheels/69/69/aa/24c58209ab280c154bb17a8ab37294226d776a5cc86aea03b4
Successfully built google-api-python-client
ERROR: awscli 1.18.5 has requirement rsa<=3.5.0,>=3.1.2, but you'll have rsa 4.0 which is incompatible.
Installing collected packages: httplib2, pyasn1, rsa, six, pyasn1-modules, oauth2client, setuptools, cachetools, google-auth, google-auth-httplib2, uritemplate, google-api-python-client
Successfully installed cachetools-4.0.0 google-api-python-client-1.7.11 google-auth-1.11.2 google-auth-httplib2-0.0.3 httplib2-0.17.0 oauth2client-4.1.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 rsa-4.0 setuptools-45.2.0 six-1.14.0 uritemplate-3.0.1

動いた。

そして、データも入ったw

やっぱり/mnt/c/xxxと/c/xxx問題か…。

今度もう一回ちゃんとお勉強しよう…。

とりあえず、今回は、動いたからOKww

lambdaにデプロイ

で、lambdaに上げてみる。

$ aws cloudformation package --template-file ./template.yaml --s3-bucket $bucket_name --output-template-file $packaged_name
$ aws cloudformation deploy --template-file $packaged_name --stack-name $stack_name

実行!

動いた

動いたーーーー!

嬉しい!長かった…。

これはこれからlinebotに組み込むのに使っていきます//


るな
るな
エンジニア