Linux容器篇-Docker容器的使用

news2024/10/5 17:42:47

文章目录

  • 前言
  • 一、Docker的安装
    • 主机环境准备
      • 关闭防火墙
      • 关闭selinux
      • 时间同步
      • 关闭 swap
      • 配置操作系统yum源
      • 配置国内Docker-ce镜像源
      • 注意
  • 二、安装docker-ce
  • 三、配置镜像加速器
      • 阿里云镜像加速器生成
  • 四、Docker的使用
    • Docker 客户端
    • 获取镜像
    • 启动容器
    • 查看所有的容器:
    • 启动已停止运行的容器
    • 后台运行
    • 进入容器
    • 导出容器
    • 导入容器快照
    • 删除容器
    • 查看网络端口
    • 查看应用程序日志
    • 查看应用程序容器的进程
    • 检查应用程序
  • 总结


前言

Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源。

Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。

容器是完全使用沙箱机制,相互之间不会有任何接口,更重要的是容器性能开销极低。


一、Docker的安装

主机环境准备

我在这里介绍centos7及以上操作系统的docker-ce安装。

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

关闭selinux

将 SELinux 设置为 disabled 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

时间同步

yum install chrony -y
systemctl start chronyd
systemctl enable chronyd
chronyc sources

关闭 swap

#临时关闭;关闭swap主要是为了性能考虑
swapoff -a
#可以通过这个命令查看swap是否关闭了
free
#永久关闭
sed -ri 's/.*swap.*/#&/' /etc/fstab

配置操作系统yum源

# CentOS 7 
mkdir /etc/yum.repos.d/repobak
mv /etc/yum.repos.d/* /etc/yum.repos.d/repobak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache

配置国内Docker-ce镜像源

这里配置阿里云镜像站的docker-ce镜像源

# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
# Step 4: 更新Docker-CE源
sudo yum makecache

注意

# 官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,您可以通过以下方式开启。同理可以开启各种测试版本等。
# vim /etc/yum.repos.d/docker-ce.repo
#   将[docker-ce-test]下方的enabled=0修改为enabled=1
#
# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
#   Loading mirror speeds from cached hostfile
#   Loaded plugins: branch, fastestmirror, langpacks
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable
#   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
#   Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]

二、安装docker-ce

# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
#   Loading mirror speeds from cached hostfile
#   Loaded plugins: branch, fastestmirror, langpacks
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable
#   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
#   Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]

设置docker开机自启动

systemctl enable docker --now

三、配置镜像加速器

(阿里云加速器)

针对Docker客户端版本大于 1.10.0 的用户

可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://5fid4glg.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

阿里云镜像加速器生成

该地址为加速器地址
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
首先需要注册一个阿里云的账号,然后登陆上面的网址,生成自己的加速器配置。
在这里插入图片描述

四、Docker的使用

Docker 客户端

docker 客户端非常简单 ,我们可以直接输入 docker 命令来查看到 Docker 客户端的所有命令选项。

[root@localhost ~]# docker

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Common Commands:
  run         Create and run a new container from an image
  exec        Execute a command in a running container
  ps          List containers
  build       Build an image from a Dockerfile
  pull        Download an image from a registry
  push        Upload an image to a registry
  images      List images
  login       Log in to a registry
  logout      Log out from a registry
  search      Search Docker Hub for images
  version     Show the Docker version information
  info        Display system-wide information

Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx
  checkpoint  Manage checkpoints
  compose*    Docker Compose
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  plugin      Manage plugins
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Swarm Commands:
  config      Manage Swarm configs
  node        Manage Swarm nodes
  secret      Manage Swarm secrets
  service     Manage Swarm services
  stack       Manage Swarm stacks
  swarm       Manage Swarm

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  wait        Block until one or more containers stop, then print their exit codes

Global Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket to connect to
  -l, --log-level string   Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Run 'docker COMMAND --help' for more information on a command.

For more help on how to use Docker, head to https://docs.docker.com/go/guides/

可以通过命令 docker command --help 更深入的了解指定的 Docker 命令使用方法。

例如我们要查看 docker stats 指令的具体使用方法:

[root@localhost ~]# docker stats --help

Usage:  docker stats [OPTIONS] [CONTAINER...]

Display a live stream of container(s) resource usage statistics

Aliases:
  docker container stats, docker stats

Options:
  -a, --all             Show all containers (default shows just running)
      --format string   Format output using a custom template:
                        'table':            Print output in table format with column headers (default)
                        'table TEMPLATE':   Print output in table format using the given Go template
                        'json':             Print in JSON format
                        'TEMPLATE':         Print output using the given Go template.
                        Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates
      --no-stream       Disable streaming stats and only pull the first result
      --no-trunc        Do not truncate output

获取镜像

如果我们本地没有 ubuntu 镜像,我们可以使用 docker pull 命令来载入 ubuntu 镜像:
$ docker pull ubuntu

[root@localhost ~]# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
7b1a6ab2e44d: Pull complete 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

启动容器

以下命令使用 ubuntu 镜像启动一个容器,参数为以命令行模式进入该容器:
$ docker run -it ubuntu /bin/bash

[root@localhost ~]# docker run -it ubuntu /bin/bash
root@3de025ab0dce:/# 

参数说明:

-i: 交互式操作。
-t: 终端。
ubuntu: ubuntu 镜像。
/bin/bash:放在镜像名后的是命令,这里我们希望有个交互式 Shell,因此用的是 /bin/bash。

要退出终端,直接输入 exit:

root@3de025ab0dce:/# cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
root@3de025ab0dce:/# 
root@3de025ab0dce:/# exit
exit
[root@localhost ~]# 

查看所有的容器:

$ docker ps -a

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                          PORTS     NAMES
3de025ab0dce   ubuntu    "/bin/bash"   2 minutes ago   Exited (0) About a minute ago             brave_jang

启动已停止运行的容器

使用 docker start 启动一个已停止的容器:

[root@localhost ~]# docker start 3de025ab0dce
3de025ab0dce

这时候查看容器状态就变成了up

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS         PORTS     NAMES
3de025ab0dce   ubuntu    "/bin/bash"   4 minutes ago   Up 7 seconds             brave_jang

后台运行

在大部分的场景下,我们希望 docker 的服务是在后台运行的,我们可以过 -d 指定容器的运行模式。

[root@localhost ~]# docker run -itd --name ubuntu-test ubuntu /bin/bash
4e7aabc94c2ed9f60772a4fb4dd1518a97941f7f58540a7fa5cbf6c91c51a53e
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                      PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   4 seconds ago   Up 2 seconds                          ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   7 minutes ago   Exited (0) 22 seconds ago             brave_jang

:加了 -d 参数默认不会进入容器,想要进入容器需要使用指令 docker exec(下面会介绍到)。
停止一个容器
停止容器的命令如下:
$ docker stop <容器 ID或容器指定的名称>

[root@localhost ~]# docker stop ubuntu-test
ubuntu-test
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   2 minutes ago    Exited (0) 2 seconds ago             ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   10 minutes ago   Exited (0) 3 minutes ago             brave_jang

进入容器

在使用 -d 参数时,容器启动后会进入后台。此时想要进入容器,可以通过以下指令进入:

docker attach

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   6 minutes ago    Up 1 second                          ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   13 minutes ago   Exited (0) 6 minutes ago             brave_jang
[root@localhost ~]# docker attach 4e7aabc94c2e
root@4e7aabc94c2e:/# 
root@4e7aabc94c2e:/# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@4e7aabc94c2e:/# exit
exit
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   6 minutes ago    Exited (0) 1 second ago              ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   13 minutes ago   Exited (0) 7 minutes ago             brave_jang

注意: 如果从这个容器退出,会导致容器的停止。
docker exec:推荐大家使用 docker exec 命令,因为此命令会退出容器终端,但不会导致容器的停止。

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   6 minutes ago    Exited (0) 1 second ago              ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   13 minutes ago   Exited (0) 7 minutes ago             brave_jang
[root@localhost ~]# docker start 4e7aabc94c2e
4e7aabc94c2e
[root@localhost ~]# docker exec -it 4e7aabc94c2e /bin/bash
root@4e7aabc94c2e:/# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@4e7aabc94c2e:/# exit
exit
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   8 minutes ago    Up 26 seconds                        ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   15 minutes ago   Exited (0) 8 minutes ago             brave_jang

导出容器

如果要导出本地某个容器,可以使用 docker export 命令。

[root@localhost ~]# docker export 4e7aabc94c2e > ubuntu.tar
[root@localhost ~]# ls
ubuntu.tar

导入容器快照

可以使用 docker import 从容器快照文件中再导入为镜像,以下实例将快照文件 ubuntu.tar 导入到镜像 test/ubuntu:v1:

[root@localhost ~]# docker import ubuntu.tar test/ubuntu:v1
sha256:f67ec2cf190888fc605c17d84dce9019feb48a3a61b97e47d9d99f9c09e1d218
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED          SIZE
test/ubuntu   v1        f67ec2cf1908   24 seconds ago   72.8MB
ubuntu        latest    ba6acccedd29   2 years ago      72.8MB

此外,也可以通过指定 URL 或者某个目录来导入,例如:

$ docker import http://example.com/exampleimage.tgz example/imagerepo

删除容器

删除容器使用 docker rm 命令:

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                      PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   18 minutes ago   Exited (0) 5 minutes ago              ubuntu-test
3de025ab0dce   ubuntu    "/bin/bash"   26 minutes ago   Exited (0) 19 minutes ago             brave_jang
[root@localhost ~]# docker rm 3de025ab0dce
3de025ab0dce
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
4e7aabc94c2e   ubuntu    "/bin/bash"   19 minutes ago   Exited (0) 6 minutes ago             ubuntu-test

注意:删除容器时,容器必须是停止状态,否则会报如错
下面的命令可以清理掉所有处于终止状态的容器。

$ docker container prune

查看网络端口

通过 docker ps 命令可以查看到容器的端口映射,docker 还提供了另一个快捷方式 docker port,使用 docker port 可以查看指定 (ID 或者名字)容器的某个确定端口映射到宿主机的端口号。

$ docker port ID 或者名字
5000/tcp -> 0.0.0.0:5000

查看应用程序日志

docker logs [ID或者名字] 可以查看容器内部的标准输出。

$ docker logs -f bf08b7f2cd89
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
192.168.239.1 - - [09/May/2016 16:30:37] "GET / HTTP/1.1" 200 -
192.168.239.1 - - [09/May/2016 16:30:37] "GET /favicon.ico HTTP/1.1" 404 -

-f: 让 docker logs 像使用 tail -f 一样来输出容器内部的标准输出。
从上面,我们可以看到应用程序使用的是 5000 端口并且能够查看到应用程序的访问日志。

查看应用程序容器的进程

我们还可以使用 docker top 来查看容器内部运行的进程

$ docker top bf08b7f2cd89
UID     PID         PPID          ...       TIME                CMD
root    23245       23228         ...       00:00:00            python app.py

检查应用程序

使用 docker inspect 来查看 Docker 的底层信息。它会返回一个 JSON 文件记录着 Docker 容器的配置和状态信息。

$ docker inspect bf08b7f2cd89
[
    {
        "Id": "bf08b7f2cd897b5964943134aa6d373e355c286db9b9885b1f60b6e8f82b2b85",
        "Created": "2018-09-17T01:41:26.174228707Z",
        "Path": "python",
        "Args": [
            "app.py"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 23245,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-09-17T01:41:26.494185806Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
......

总结

随手分享,没什么技术含量,希望可以给入坑容器的小伙伴们提供一些帮助。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1876553.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

逆风而行:提升逆商,让困难成为你前进的动力

一、引言 生活&#xff0c;总是充满了未知与变数。有时&#xff0c;我们会遇到阳光明媚的日子&#xff0c;享受着宁静与和谐&#xff1b;但更多时候&#xff0c;我们却不得不面对那些突如其来的坏事件&#xff0c;如工作的挫折、人际关系的困扰、健康的挑战等。这些事件如同突…

每日一题——Python实现PAT乙级1072 开学寄语(举一反三+思想解读+逐步优化)五千字好文

一个认为一切根源都是“自己不够强”的INTJ 个人主页&#xff1a;用哲学编程-CSDN博客专栏&#xff1a;每日一题——举一反三Python编程学习Python内置函数 Python-3.12.0文档解读 目录 我的写法 代码点评 时间复杂度分析 空间复杂度分析 总结 我要更强 优化建议 优…

在HBuilder X中ElementUI框架的搭建

前言 本文将详解基于Vue-cli脚手架搭建的项目如何使用ElementUI &#xff1f;所以在学习本篇文章内容之前建议先学习vue-cli脚手架项目的搭建和学习 使用HbuilderX快速搭建vue-cil项目https://mp.csdn.net/mp_blog/creation/editor/140043776 ElementUI框架: Element&#xff…

气膜建筑消防设计:安全与创新的完美结合—轻空间

随着气膜建筑在各个领域的广泛应用&#xff0c;其消防安全问题也日益受到关注。气膜建筑由于其独特的结构和材料&#xff0c;在消防设计上面临着不同于传统建筑的挑战和要求。轻空间将深入探讨气膜建筑的消防设计原则、具体措施以及未来的发展方向。 气膜建筑的消防设计原则 1.…

深入分析 Android BroadcastReceiver (七)

文章目录 深入分析 Android BroadcastReceiver (七)1. 高级应用场景1.1 示例&#xff1a;动态权限请求1.2 示例&#xff1a;应用内通知更新 2. 安全性与性能优化2.1 示例&#xff1a;设置权限防止广播攻击2.2 示例&#xff1a;使用 LocalBroadcastManager2.3 示例&#xff1a;在…

大模型应用-多模态和大模型是如何相互成就的

前言 如果单纯的将大模型用来聊天&#xff0c;那就是low了。 而多模态赋予了大模型更多的现实价值&#xff0c;大模型则助力多模态变得更强大。 多模态 我们所处的是一个物理世界&#xff0c;不同事物之间模态多种多样&#xff0c;即便是简单的文本&#xff0c;按照语言&am…

轻量级模型,重量级性能,TinyLlama、LiteLlama小模型火起来了

小身板&#xff0c;大能量。 当大家都在研究大模型&#xff08;LLM&#xff09;参数规模达到百亿甚至千亿级别的同时&#xff0c;小巧且兼具高性能的小模型开始受到研究者的关注。 小模型在边缘设备上有着广泛的应用&#xff0c;如智能手机、物联网设备和嵌入式系统&#xff0…

Actor-agnostic Multi-label Action Recognition with Multi-modal Query

标题&#xff1a;基于多模态查询的非特定行为者多标签动作识别 源文链接&#xff1a;https://openaccess.thecvf.com/content/ICCV2023W/NIVT/papers/Mondal_Actor-Agnostic_Multi-Label_Action_Recognition_with_Multi-Modal_Query_ICCVW_2023_paper.pdfhttps://openaccess.t…

ZYNQ MPSOC浅说

1 MPSOC PL端 Zynq UltraScale MPSoC PL 部分等价于 FPGA。简化的 FPGA 基本结构由 6 部分组成&#xff0c;分别为可编程输入/输出单元、基本可编程逻辑单元、嵌入式块RAM、丰富的布线资源、底层嵌入功能单元和内嵌专用硬核等。 2 MPSOC PS端 MPSoC 实际上是一个以处理器为…

Linux Doxygen快速生成文档

此前写过一篇编写Doxygen格式的注释以用于生成文档,点击以查阅, Doxygen常用语法与字段记录,但是当时用的windows桌面版的doxygen,最近使用ubuntu编写代码想直接使用doxygen生成,故写下此博客 Doxygen Doxygen是一个用于生成软件文档的工具&#xff0c;它可以从代码中提取注释…

Java中System的用法

System指的是当前进程运行的操作系统&#xff0c;属于java.lang包下面的类 常见的用法有以下几种&#xff1a; 第一种简单,我们直接上第二种方法吧 currentTimeMills()用法 // 演示currentTimeMillis方法public static void main(String[] args) {// 获取当前时间所对应的毫秒…

每日一道算法题 面试题 08.08. 有重复字符串的排列组合

题目 面试题 08.08. 有重复字符串的排列组合 - 力扣&#xff08;LeetCode&#xff09; Python class Solution:def permutation(self, S: str) -> List[str]:# 以索引记录字符是否用过lelen(S)idx[_ for _ in range(le) ]# 组合得到的字符串combine[]*leans[]# 递归def fu…

哪吒汽车,正在等待“太乙真人”的拯救

文丨刘俊宏 在360创始人、哪吒汽车股东周鸿祎近日连续且着急的“督战”中&#xff0c;哪吒汽车&#xff08;下简称哪吒&#xff09;终究还是顶不住了。 6月26日&#xff0c;哪吒通过母公司合众新能源在港交所提交了IPO文件&#xff0c;急迫地希望成为第五家登陆港股的造车新势力…

第二十二课,列表的操作函数(二)

一&#xff0c;列表.append(元素) 该函数用于向列表的末尾追加一个新元素 你可以把列表想象成一个班级&#xff0c;列表.append(元素)则像是往班里插入一个新同学 二&#xff0c;列表.insert(下标, 元素) 在指定下标处&#xff0c;插入指定的元素 不同于列表.append(元素)函…

JAVA医院绩效考核系统源码:三级公立医院绩效考核系统源码 可源码交付,支持二开

JAVA医院绩效考核系统源码&#xff1a;三级公立医院绩效考核系统源码 可源码交付&#xff0c;支持二开 医院绩效考核系统是一个集数据采集、分析、评估、反馈于一体的信息化工具&#xff0c;旨在提高医疗服务质量、优化资源配置、促进医院可持续发展。以下是对医院绩效考核系统…

【React】第二个组件的一点小问题(JSX元素需要被包裹)

能看出为什么报错吗&#xff1f; 它告诉我们JSX元素需要被包裹&#xff0c;此时只需在所有元素外套一层标签&#xff08;空标签也可以哦&#xff09; 专业点就是要有一个根元素 注释&#xff1a; ctrl / 效果是 {/* */}这样 三元运算符&#xff1a;同CPP 循环输出数组&#x…

【wsl2】WIN11借助wsl2挂载ext4磁盘

我有一块ext4文件系统的硬盘&#xff0c;想要在win11上访问&#xff0c;我们可以通过wsl2进行挂载 wsl2的安装就跳过了&#xff0c;可以自行搜索安装。 安装完成后 >>> GET-CimInstance -query "SELECT * from Win32_DiskDrive"通过这个命令&#xff0c;可…

[算法]——堆排序(C语言实现)

简单的介绍一下用堆排序的算法对整形数据的数据进行排序。 一、堆的概念 堆是具有下列性质的完全二叉树&#xff1a;每个结点的值都大于或等于其左右孩子节点的值&#xff0c;称为大顶堆&#xff1b;或者每个结点的值都小于或等于其左右孩子结点的值&#xff0c;称为小顶堆。 …

ElasticSearch 和 MySQL的区别

MySQLElasticSearch 数据库&#xff08;database&#xff09;索引&#xff08;index&#xff09;数据表&#xff08;table&#xff09; 类型&#xff08;type&#xff09; 记录文档&#xff08;document&#xff0c;json格式&#xff09; 一、ES基础命令 1. ES cat查询命令 2.…

超简单的nodejs使用log4js保存日志到本地(可直接复制使用)

引入依赖 npm install log4js 新建配置文件logUtil.js const log4js require(log4js);// 日志配置 log4js.configure({appenders: {// 控制台输出consoleAppender: { type: console },// 文件输出fileAppender: {type: dateFile,filename: ./logs/default, //日志文件的存…