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

相关推荐
南猿北者3 小时前
docker容器
docker·容器
二十雨辰3 小时前
[linux]docker基础
linux·运维·docker
time never ceases4 小时前
使用docker方式进行Oracle数据库的物理迁移(helowin/oracle_11g)
数据库·docker·oracle
YCyjs4 小时前
K8S群集调度二
云原生·容器·kubernetes
Hoxy.R4 小时前
K8s小白入门
云原生·容器·kubernetes
MonkeyKing_sunyuhua6 小时前
ubuntu22.04 docker-compose安装postgresql数据库
数据库·docker·postgresql
追风林6 小时前
mac m1 docker本地部署canal 监听mysql的binglog日志
java·docker·mac
€☞扫地僧☜€7 小时前
docker 拉取MySQL8.0镜像以及安装
运维·数据库·docker·容器
茶馆大橘7 小时前
微服务系列六:分布式事务与seata
分布式·docker·微服务·nacos·seata·springcloud
全能全知者9 小时前
docker快速安装与配置mongoDB
mongodb·docker·容器