From ee8bdc2fef3ef220959dd71b812f9a2574191543 Mon Sep 17 00:00:00 2001 From: barney <15270405776@163.com> Date: Sun, 19 Feb 2023 22:21:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=AC=AC=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker_tutorial.code-workspace | 8 ++++++++ python/.dockerignore | 2 ++ python/Dockerfile | 8 ++++++++ python/hello.py | 1 + 4 files changed, 19 insertions(+) create mode 100644 docker_tutorial.code-workspace create mode 100644 python/.dockerignore create mode 100644 python/Dockerfile create mode 100644 python/hello.py diff --git a/docker_tutorial.code-workspace b/docker_tutorial.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/docker_tutorial.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/python/.dockerignore b/python/.dockerignore new file mode 100644 index 0000000..96571bf --- /dev/null +++ b/python/.dockerignore @@ -0,0 +1,2 @@ +__pycache__ +env \ No newline at end of file diff --git a/python/Dockerfile b/python/Dockerfile new file mode 100644 index 0000000..df6ed86 --- /dev/null +++ b/python/Dockerfile @@ -0,0 +1,8 @@ +# 将image文件继承与官方的3.8版本的Python +FROM python:3.8 +# 将当前目录下的所有文件(除了.dockerignore排除的路径),都拷贝进image文件的/app目录。 +COPY . /app +# 指定接下来的工作路径为/app +WORKDIR /app +# 在/app目录下,运行python文件 +CMD python3 hello.py \ No newline at end of file diff --git a/python/hello.py b/python/hello.py new file mode 100644 index 0000000..e75154b --- /dev/null +++ b/python/hello.py @@ -0,0 +1 @@ +print("hello world") \ No newline at end of file