一、目录
- docker 指令
1. 创建镜像
2. 保存镜像
3. 加载镜像
4. 删除容器
5. 删除镜像
6. 查看容器日志
7. 查看docker 占用内存情况
8. 查看docker 根目录(安装路径)
9. 创建一个容器
二、实现
- docker指令
1 创建镜像
docker commit fd69960ed65f jyf:0.0.1
- 保存镜像
docker save -o my.tar hello-word:latest
- 加载镜像
docker load -i my.tar
- 删除容器
docker rm CONTAINER-ID #删除容器id, 或者>>docker rm name #容器名字
批量删除
docker rm $(docker ps -a -q)
- 删除镜像
docker rmi image-id #删除镜像id
- 查看容器日志
docker logs CONTAINER-ID #容器id
- 查看docker 占用内存情况
[root@localhost ~]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 81 41 37.12GB 18.87GB (50%)
Containers 58 18 33.98GB 32.39GB (95%)
Local Volumes 42 25 1.598GB 1.492GB (93%)
Build Cache 130 0 562.7MB 562.7MB
- 查看docker 根目录(安装路径)
[root@dockermain ~]# docker info Client: Docker Engine - Community
Version: 24.0.1 Context: default Debug Mode: false Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.4
Path: /usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.)
Version: v2.18.1
Path: /usr/libexec/docker/cli-plugins/docker-compose scan: Docker Scan (Docker Inc.)
Version: v0.23.0
Path: /usr/libexec/docker/cli-plugins/docker-scanServer: Containers: 58 Running: 21 Paused: 0 Stopped: 37
Images: 141 Server Version: 24.0.1 Storage Driver: overlay2
Backing Filesystem: xfs Supports d_type: true Using metacopy:
false Native Overlay Diff: true userxattr: false Logging Driver:
json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins:
Volume: local Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries
splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc Init Binary: docker-init containerd version:
3dce8eb055cbb6872793272b4f20ed16117344f8 runc version:
v1.1.7-0-g860f061 init version: de40ad0 Security Options: seccomp
Profile: builtin cgroupns Kernel Version:
5.14.0-284.11.1.el9_2.x86_64 Operating System: AlmaLinux 9.2 (Turquoise Kodkod) OSType: linux Architecture: x86_64 CPUs: 16
Total Memory: 31.09GiB Name: dockermain ID:
b1b354b2-ccd6-4204-9c1d-78ca30da0712
Docker Root Dir: /home/dockerdata #根目录
Debug Mode: false
Experimental: false Insecure Registries:
10.120.130.49:5000
127.0.0.0/8 Registry Mirrors: http://hub-mirror.c.163.com/ Live Restore Enabled: false
- 创建一个容器
镜像选取:docker pull pytorch/pytorch:1.9.1-cuda11.1-cudnn8-devel
docker run -it --gpus '"device=1,2"' --name leinao -v /tmp:/tmp pytorch/pytorch:pytorch:1.9.1-cuda11.1-cudnn8-devel /bin/bash
docker run -it --gpus '"device=2,3"' -v /jiayafei_linux/:/home/ --name llm_g pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel /bin/bashdocker run -it --gpus '"device=0"' -v /jiayafei_linux/:/home/ --name nodes_0 -p8201:8010 pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel /bin/bash
docker run -it --gpus '"device=1"' -v /jiayafei_linux/:/home/ --name nodes_1 -p8202:8010 pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel /bin/bashdocker run -it --gpus all --name llm-01 -v /:/home -p8011:8011 -p8012:8012 -p8013:8013 -p8014:8014 pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel /bin/bash