Docker commands on Linux (WSL)

Docker commands:

1.Docker service

bash 复制代码
  # start docker service by root
    sudo service docker start

  # stop docker service by root
    sudo service docker stop 

  # show docker status
    service docker status

2.Docker image

bash 复制代码
  # Show docker image
    docker images

  # Delete docker image
    docker rmi {image ID or Name}

  # Docker image backup:
  # 列出现有镜像
    docker images
  # 选择要备份的镜像,并保存为 tar 文件
    docker save -o my_image_backup.tar my_image:latest
    例如:docker save -o compreface_image_backup.tar exadel/compreface-core:1.2.0 exadel/compreface-fe:1.2.0 exadel/compreface-admin:1.2.0 exadel/compreface-api:1.2.0 exadel/compreface-postgres-db:1.2.0
  # 验证 tar 文件
    ls -lh my_image_backup.tar
    例如:ls -lh compreface_image_backup.tar

2.Docker container

bash 复制代码
  # Show docker container
    docker ps -a

  # Delete docker container
    docker rm {container ID or Name}

  # show docker log
    docker logs {container ID or Name}

  # Go to container
    docker exec -it {container ID or Name} /bin/bash
    docker exec -it {container ID or Name} /bin/sh

  # Start a contrainer
    docker run -it \
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner \
	-v /var/run/docker.sock:/var/run/docker.sock \
	--rm --name gitlab-runner gitlab/gitlab-runner:latest
  # Doesn't save a container
    docker run -it --rm --name {container name} -p {expose port:APP port} {docker image REPOSITORY:TAG} 
  # Save a container
    docker run --name {container name} -p {expose port:APP port} {docker image REPOSITORY:TAG} 

Linux commands:

bash 复制代码
 # Go to Ubuntu from Windows
    \\wsl$\Ubuntu-18.04

 # Create a file
    touch {file name}

 # Delete a file
    rm {file name}

 # Create a folder
    mkdir {directory name}

 # Delete a folder
    rm -rf {directory name}

 # Copy directory
    cp -r {from} {to}

 # show file contents
    cat {file path}
    例如:cat /etc/nginx/conf.d/nginx.conf

 # 查看物理 cpu 数:
    cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
 # 查看每个物理 cpu 中 核心数(core 数):
    cat /proc/cpuinfo | grep "cpu cores" | uniq
 # 查看总的逻辑 cpu 数(processor 数):
    cat /proc/cpuinfo| grep "processor"| wc -l
 # 查看 cpu 型号:
    cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
 # lscpu 命令可以同时看到上述信息。
    lscpu

 # 查看IP和PORT是否畅通?
    echo > /dev/tcp/{IP}/{PORT} && echo "Port is open"
    例如:echo > /dev/tcp/222.178.221.130/20001 && echo "Port is open"
相关推荐
檬柠wan2 分钟前
CentOS 7 yum 无法安装软件的解决方法
linux·运维·centos
软件黑马王子3 分钟前
Windows 系统下用 VMware 安装 CentOS 7 虚拟机超详细教程(包含VMware和镜像安装包)
linux·windows·centos
怼您恏10316 分钟前
Linux进阶——shell脚本语言
linux·运维·服务器
禁默7 分钟前
Linux 指令初探:开启终端世界的大门
linux·运维·服务器
飞猪~16 分钟前
docker相关命令
运维·docker·容器
珹洺30 分钟前
Linux红帽:RHCSA认证知识讲解(十 二)调试 SELinux,如何管理 SELinux 的运行模式、安全策略、端口和上下文策略
linux·运维·服务器·网络·安全
孙同学_32 分钟前
【Linux篇】基础IO - 揭秘重定向与缓冲区的管理机制
android·java·linux
cosX+sinY32 分钟前
ubuntu 20.04 编译运行LeGo_LOAM 跑数据集 并且保存pcl文件
linux·ubuntu·机器人·bash
cosX+sinY32 分钟前
ubuntu 20.04 编译和运行SC-LeGo-LOAM
linux·ubuntu·机器人·bash
千羽星弦41 分钟前
Kubernetes 集群搭建(一):k8s 从环境准备到 Calico 网络插件部署(1.16版本)
网络·容器·kubernetes