docker pull python:3.5
docker ps #查看镜像
创建文件
print("Hello!")
通过简单的编写Dockerfile实现
编写Dockerfile文件
FROM python:3.5
COPY . /usr/src/mypython
WORKDIR /usr/src/mypython
ENTRYPOINT [ "python" ]
CMD [ "./" ]
运行命令:
docker build -t yqq/python .
得出结果:
G:\python\myapp>docker build -t yqq/python .
Sending build context to Docker daemon 3.072kB
Step 1/5 : FROM python:3.5
---> 85c44ea592e4
Step 2/5 : COPY . /usr/src/mypython
---> Using cache
---> 5f97213fb129
Step 3/5 : WORKDIR /usr/src/mypython
---> Using cache
---> 3d61aeccdc62
Step 4/5 : ENTRYPOINT [ "python" ]
---> Using cache
---> 1d4f39a84aa5
Step 5/5 : CMD [ "./" ]
---> Using cache
---> a167b4602a06
Successfully built a167b4602a06
Successfully tagged yqq/python:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
再运行命令:
docker run a167b4602a06
得出结果:
G:\python\myapp>docker run a167b4602a06
Hello!