{ "registry-mirrors": [
"https://registry.docker-cn.com",
"https://hub-mirror.c.163.com",
"https://ustc-edu-cn.mirror.aliyuncs.com",
"https://mirror.baidubce.com"
],
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"features": {
"buildkit": false
}
}
pytorch的镜像
----python
--|
|--Dockerfile
|--requirements.txt
|--test.py
FROM python:3.7.13
WORKDIR ./
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./test.py" ]
requirements.txt(为空)
test.py
for i in range(100000):
print(1)
在python目录中,shift+右键,打开powershell,执行:
docker build -t test . # 就会像pull一样进行下载与创建镜像
docker run test
注:可在 https://hub.docker.com/_/python中“How to use this image”部分找到Dockerfile文件中的命令
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./your-daemon-or-script.py" ]
docker ps -a # 找到CONTAINER ID
# 运行结果
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3aa7b7b18f6f python:3.7.13 "python3" 30 minutes ago Up 30 minutes mystifying_meitner
# 在powershell中运行命令
## copy 主机->容器
docker cp test.py 3aa7b7b18f6f:/
## copy 容器->主机
docker cp 3aa7b7b18f6f:/bin ./ # 用docker cp mystifying_meitner:/bin ./同样
挂载目录:docker run -v D:/python:/mnt python:3.7.13 # /mnt /为linux目录格式
挂载目录:docker run -v D:/python:/mnt python:3.7.13# -v 本地目录:/容器目录 镜像名称:镜像tag
挂载目录有多种方式,这只是一种方式
# 解决闪退问题
docker run -it --name test -v **:/mnt -p 5000:5000 node5000:latest
ps:发现在编辑器种输入:/ 会变成
****/python> docker images #查看
REPOSITORY TAG IMAGE ID CREATED SIZE
python 3.7.13 27599ef95971 2 days ago 906MB
****/python>docker save python -o python37.tar
然后在执行代码的路径下会出现一个python37.tar文件
****/python>docker load -i python37.tar
python 换源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
https://www.urlos.com/docker/thread-89652-1-1.html
报错:failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head "https://registry.docker-cn.com/v2/library/python/manifests/3?ns=docker.io": unable to connect to 106.14.52.175:443. Do you need an HTTP proxy?
解决:https://www.jianshu.com/p/56241136130d
Docker 创建paddlepaddle https://blog.csdn.net/sinat_41581976/article/details/121069031
【【Docker】Dockerfile用法全解析-哔哩哔哩】 https://b23.tv/a5JfHo7
[windows端的portable版本,需要安装virtual box ](https://portapps.io/app/docker-toolbox-portable/)
1.Docker 网络端口的映射:局域网文件传输
写给孩子看的 Kubernetes 动画指南【中英字幕】