Back_To_Home..

docker-docs

docs

Docker Docs

Dockerfile: https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds

Docker Compose: https://docs.docker.com/compose/gettingstarted/

docker镜像网站

https://mcr.microsoft.com/en-us/

hub.docker.com/

https://catalog.ngc.nvidia.com/

https://ghcr.io

好用的镜像

mcr.microsoft.com/devcontainers/universal:2

https://www.docker.com/

mac 使用orbstack可以轻量化使用docker,缺点是目前还不能以本地镜像重新构建镜像。

Docker hub

https://hub.docker.com/

私有化部署Docker Hub可以使用Harbor等开源容器镜像仓库来实现,以下是使用Harbor进行私有化部署的一般步骤:

准备工作

下载和配置Harbor

安装和启动Harbor

访问和使用Harbor

# 登录Harbor仓库
docker login your_harbor_url
# 标记本地镜像
docker tag your_image:tag your_harbor_url/project/your_image:tag
# 推送镜像到Harbor
docker push your_harbor_url/project/your_image:tag

配置与维护

常用命令

# 查看、删除容器
docker ps [-a] [| grep keyword_to_search]
docker rm container_name/id
# 查看、删除镜像
docker images [| grep keyword_to_search]
docker rmi image_name/id
# 数据复制
docker cp /path/of/data  container_name/id:/new/path/of/data
# 删除缓存
docker builder prune
# 构建容器
docker run -d -p 8000:8000 -v ./:/workspace -name container_name -it image_name

docker 运行示例

docker run --gpus all \
-v ${PWD}:/workspace \
--shm-size=8gb \
--ipc=host \
--ulimit memlock=-1 \
--ulimit stack=67108864 \
-p 18080:18080 \
-it tensorrt:trt8.5.1-cu11.3-ubuntu2004

Win Docker Desktop

迁移docker镜像

wsl export docker-desktop docker-desktop.tar
wsl export docker-desktop-data docker-desktop-data.tar
wsl unregister docker-desktop wsl unregister docker-desktop-data
wsl import docker-desktop-data F:-desktop-data docker-desktop-data.tar
wsl import docker-desktop F:-desktop docker-desktop.tar

GPU测试

service docker start
docker run -gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark

重置密码

ubuntu2004 config default-user root
passwd torch
ubuntu2004 config default-user torch

k8s等集群服务部署

Docker swarn

k8s

示例:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
© 2025 ai-charlie   •  Powered by Soopr   •  Theme  Moonwalk