docker常用指令

一、目录

  1. docker 指令
    1. 创建镜像
    2. 保存镜像
    3. 加载镜像
    4. 删除容器
    5. 删除镜像
    6. 查看容器日志
    7. 查看docker 占用内存情况
    8. 查看docker 根目录(安装路径)
    9. 创建一个容器

二、实现

  1. docker指令
    1 创建镜像

    docker commit  fd69960ed65f  jyf:0.0.1
    
  1. 保存镜像

    docker save -o my.tar hello-word:latest

  1. 加载镜像

    docker load -i my.tar

  1. 删除容器

    docker rm CONTAINER-ID #删除容器id, 或者>>docker rm name #容器名字
    批量删除
    docker rm $(docker ps -a -q)

  2. 删除镜像

    docker rmi image-id #删除镜像id

  3. 查看容器日志

    docker logs CONTAINER-ID #容器id

  4. 查看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

  5. 查看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-scan

Server: 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

  1. 创建一个容器

    镜像选取: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/bash

    docker 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/bash

    docker 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

相关推荐
桂月二二2 小时前
Java与容器化:如何使用Docker和Kubernetes优化Java应用的部署
java·docker·kubernetes
Smile丶凉轩5 小时前
Docker核心技术和实现原理
运维·docker·容器
清风细雨_林木木5 小时前
Docker使用——国内Docker的安装办法
运维·docker·容器
dessler6 小时前
Docker-Dockerfile讲解(三)
linux·运维·docker
一休哥助手6 小时前
深入理解 Docker 网桥配置与网络管理
docker·容器·eureka
PittDing7 小时前
【更新】Docker新手入门教程2:在Windows系统通过compose创建多个mysql镜像并配置应用
windows·mysql·docker
Mitch3118 小时前
【漏洞复现】CVE-2014-3120 & CVE-2015-1427 Expression Injection
运维·web安全·elasticsearch·docker·apache
m0_748251089 小时前
docker安装nginx,docker部署vue前端,以及docker部署java的jar部署
java·前端·docker
m0_7482402510 小时前
docker--压缩镜像和加载镜像
java·docker·eureka
颜淡慕潇11 小时前
【K8S问题系列 | 20 】K8S如何删除异常对象(Pod、Namespace、PV、PVC)
后端·云原生·容器·kubernetes