LoginSignup
0
0

More than 1 year has passed since last update.

DockerでPythonを1回だけ実行したいとき

Last updated at Posted at 2022-07-30

Docker Hubの公式ページのやつそのままだとエラーになったので。

Python - Official Image | Docker Hub

コマンドプロンプトかターミナルかでカレントディレクトリの参照の仕方が変わるみたい。

  • コマンドプロンプトで実行する時は%cd%
  • エディタのターミナル系で実行する時は$(pwd)

実行するときはダブルクォーテーションを付けるといいっぽい。
Python2系はpython:2を使ってください。

  • コマンドプロンプト(Windows)
docker run -it --rm -v "%cd%:/usr/src/myapp" -w /usr/src/myapp python:3 python main.py
  • Windows PowerShell、
docker run -it --rm -v "$(pwd):/usr/src/myapp" -w /usr/src/myapp python:3 python main.py
0
0
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
0
0