当前位置: 首页 > news >正文

Docker 笔记(五)--链接

这篇笔记记录了Docker 的Link。
官方文档: Legacy container links - Communication across links

目录

  • 参考
  • Legacy container links
    • Connect using network port mapping
    • Connect with the linking system
      • The importance of naming
    • Communication across links
      • Environment variables
      • Important notes on Docker environment variables
      • Updating the /etc/hosts file

参考

  • 链接: docker官方文档
  • 链接: Docker 入门到实战教程(四)容器链接

Legacy container links

遗留的容器链接

Warning

The --link flag is a legacy feature of Docker. It may eventually be removed. Unless you absolutely need to continue using it, we recommend that you use user-defined networks to facilitate communication between two containers instead of using --link. One feature that user-defined networks do not support that you can do with --link is sharing environment variables between containers. However, you can use other mechanisms such as volumes to share environment variables between containers in a more controlled way.

See Differences between user-defined bridges and the default bridge for some alternatives to using --link.

–link标志是Docker的遗留功能。它最终可能会被移除。除非您绝对需要继续使用它,否则我们建议您使用用户定义的网络实现两个容器之间的通信,而不是使用–link。用户定义的网络不支持在容器之间共享环境变量,但–link可以。但是,您可以使用其他机制(如卷)以更可控的方式在容器之间共享环境变量。

有关使用–link的一些替代方法,请参阅用户定义网桥和默认网桥之间的差异

The information in this section explains legacy container links within the Docker default bridge network which is created automatically when you install Docker.

本节中的信息解释了Docker默认网桥网络中的遗留容器链接,该网络是在安装Docker时自动创建的。

Before the Docker networks feature, you could use the Docker link feature to allow containers to discover each other and securely transfer information about one container to another container. With the introduction of the Docker networks feature, you can still create links but they behave differently between default bridge network and user defined networks.

在使用Docker网络功能之前,您可以使用Docker链接功能来允许容器互相发现,并将有关一个容器的信息安全地传输到另一个容器。随着Docker网络功能的引入,您仍然可以创建链接,但它们在默认网桥网络和用户定义网络之间的行为不同。

This section briefly discusses connecting via a network port and then goes into detail on container linking in default bridge network.

本节简要讨论通过网络端口进行连接,然后详细介绍默认网桥网络中的容器链接。

Connect using network port mapping

使用网络端口映射进行连接

Let’s say you used this command to run a simple Python Flask application:

假设您使用此命令来运行一个简单的Python Flask应用程序:

在这里插入图片描述

Note

Containers have an internal network and an IP address. Docker can have a variety of network configurations. You can see more information on Docker networking here.

注意
容器有一个内部网络和一个IP地址。Docker可以有多种网络配置。你可以在这里看到更多关于Docker网络的信息。

When that container was created, the -P flag was used to automatically map any network port inside it to a random high port within an ephemeral port range on your Docker host. Next, when docker ps was run, you saw that port 5000 in the container was bound to port 49155 on the host.

创建该容器时,-P标志用于自动将内部任意网络端口临时映射到Docker主机的随机高端口上。接下来,当docker ps运行时,您看到容器中的端口5000绑定到主机上的端口49155。

在这里插入图片描述
You also saw how you can bind a container’s ports to a specific port using the -p flag. Here port 80 of the host is mapped to port 5000 of the container:

您还看到,您可以使用-p标志将容器的端口绑定到指定端口上。这里,主机的端口80被映射到容器的端口5000:

在这里插入图片描述
And you saw why this isn’t such a great idea because it constrains you to only one container on that specific port.

您看到了这不是一个好主意,因为它将限制只有一个容器可以使用这个指定端口。

Instead, you may specify a range of host ports to bind a container port to that is different than the default ephemeral port range:

相反,您可以指定一系列主机端口来绑定容器端口,这些端口不同于默认的临时端口范围:

在这里插入图片描述
This would bind port 5000 in the container to a randomly available port between 8000 and 9000 on the host.

这将把容器中的端口5000绑定到主机上8000到9000之间的随机可用端口。

There are also a few other ways you can configure the -p flag. By default the -p flag binds the specified port to all interfaces on the host machine. But you can also specify a binding to a specific interface, for example only to the localhost.

还有一些其他方法可以配置-p标志。默认情况下,-p标志将指定的端口绑定到主机上的所有接口。但是,您也可以指定绑定到特定接口上,例如仅指定到localhost的绑定。

在这里插入图片描述
This would bind port 5000 inside the container to port 80 on the localhost or 127.0.0.1 interface on the host machine.

这将把容器内的5000端口绑定到本地主机localhost或127.0.0.1的80端口上。

Or, to bind port 5000 of the container to a dynamic port but only on the localhost, you could use:

或者,要将容器的5000端口绑定到在本地主机的动态端口上,您可以使用:

在这里插入图片描述
You can also bind UDP and SCTP (typically used by telecom protocols such as SIGTRAN, Diameter, and S1AP/X2AP) ports by adding a trailing /udp or /sctp. For example:

您还可以通过添加尾部/udp或/sctp来绑定UDP和SCTP(一般SIGTRAN、Diameter和S1AP/X2AP等协议会使用)的端口。例如 :

在这里插入图片描述
You also learned about the useful docker port shortcut which showed us the current port bindings. This is also useful for showing you specific port configurations. For example, if you’ve bound the container port to the localhost on the host machine, then the docker port output reflects that.

您还了解了docker端口速查方式,它向我们展示了当前的端口绑定。这对于显示指定端口的配置也很有用。例如,如果您已经将容器端口绑定到主机上的localhost,那么docker端口输出就会反映这一点。

在这里插入图片描述
Note

The -p flag can be used multiple times to configure multiple ports.

注意
-p标志可以多次用于配置多个端口。

Connect with the linking system

使用链接系统进行连接

Note
This section covers the legacy link feature in the default bridge network. Refer to differences between user-defined bridges and the default bridge for more information on links in user-defined networks.

注意
本节介绍默认bridge网络中的link功能。关于用户自定义网络中的用法,请参阅用户定义网桥和默认网桥之间的差异

Network port mappings are not the only way Docker containers can connect to one another. Docker also has a linking system that allows you to link multiple containers together and send connection information from one to another. When containers are linked, information about a source container can be sent to a recipient container. This allows the recipient to see selected data describing aspects of the source container.

网络端口映射并不是Docker容器相互连接的唯一方式。Docker还有一个链接系统,可以将多个容器链接在一起,并将连接信息从一个容器发送到另一个容器。当链接容器时,可以将源容器的信息发送到接收容器。这允许接收容器查看描述源容器各方面的选定数据。

The importance of naming

To establish links, Docker relies on the names of your containers. You’ve already seen that each container you create has an automatically created name; indeed you’ve become familiar with our old friend nostalgic_morse during this guide. You can also name containers yourself. This naming provides two useful functions:

为了建立链接,Docker依赖于容器的名称。您已经看到,您创建的每个容器都有一个自动创建的名称;事实上,在本指南中,您已经熟悉了我们的老朋友"nostalgic_morse"。您也可以自己命名容器。此命名提供了两个有用的功能:

  1. It can be useful to name containers that do specific functions in a way that makes it easier for you to remember them, for example naming a container containing a web application web.
  2. It provides Docker with a reference point that allows it to refer to other containers, for example, you can specify to link the container web to container db.

1.以一种更容易记住的方式命名执行特定功能的容器会很有用,例如命名一个包含web应用程序的容器叫web。
2.它为Docker提供了一个参照点,允许它引用其他容器,例如,您可以指定将容器web链接到容器db。

You can name your container by using the --name flag, for example:

您能使用–name标识命名您的容器,举个例子:

在这里插入图片描述This launches a new container and uses the --name flag to name the container web. You can see the container’s name using the docker ps command.

启动一个新容器,使用–name标识命名它web。您可以使用docker ps命令查看容器的名称。

在这里插入图片描述
You can also use docker inspect to return the container’s name.

您也可以使用docker inspect命令查看容器的名称。

Note
Container names must be unique. That means you can only call one container web. If you want to re-use a container name you must delete the old container (with docker container rm) before you can create a new container with the same name. As an alternative you can use the --rm flag with the docker run command. This deletes the container immediately after it is stopped.

容器名称必须唯一。这意味着您只能定义一个容器叫web。如果要重复使用容器名称,则必须删除旧容器(使用docker容器rm),然后才能创建具有相同名称的新容器。作为一种选择,您可以将–rm标志与docker run命令一起使用。这会在容器停止后立即删除它。

Communication across links

通过链接通讯

Links allow containers to discover each other and securely transfer information about one container to another container. When you set up a link, you create a conduit between a source container and a recipient container. The recipient can then access select data about the source. To create a link, you use the --link flag. First, create a new container, this time one containing a database.

链接允许容器发现彼此,并将有关一个容器的信息安全地传输到另一个容器。设置链接时,将在源容器和接收容器之间创建管道。然后,接收容器可以访问有关源的选定数据。要创建链接,可以使用–link标识。首先,创建一个新的容器,这次是一个包含数据库的容器。

在这里插入图片描述This creates a new container called db from the training/postgres image, which contains a PostgreSQL database.

这次使用training/postgres映像创建一个名为db的新容器,它包含一个PostgreSQL数据库。

Now, you need to delete the web container you created previously so you can replace it with a linked one:

现在,您需要删除之前创建的web容器,以便将其替换为链接的容器:

在这里插入图片描述Now, create a new web container and link it with your db container.

现在,创建一个新web容器,并将它与db容器链接:

在这里插入图片描述
This links the new web container with the db container you created earlier. The --link flag takes the form:

–link <name or id>:alias

这将新的web容器与您之前创建的数据库容器链接起来。–link标识采用以下形式:
–link <name or id> :alias

Where name is the name of the container we’re linking to and alias is an alias for the link name. That alias is used shortly. The --link flag also takes the form:

–link <name or id>

其中name是我们链接到的容器的名称,alias是链接名称的别名。这个别名也可以省略。–link标识也采用以下形式:
–link <name or id>

In this case the alias matches the name. You could write the previous example as:

在这种情况下,别名与名称一致。您可以将前面的示例写成:

在这里插入图片描述
Next, inspect your linked containers with docker inspect:

接下来,使用docker inspect命令查看您链接的容器:

在这里插入图片描述

You can see that the web container is now linked to the db container web/db. Which allows it to access information about the db container.

您可以看到web容器现在已链接到db容器-web/db。这允许web容器访问有关db容器的信息。

So what does linking the containers actually do? You’ve learned that a link allows a source container to provide information about itself to a recipient container. In our example, the recipient, web, can access information about the source db. To do this, Docker creates a secure tunnel between the containers that doesn’t need to expose any ports externally on the container; when we started the db container we did not use either the -P or -p flags. That’s a big benefit of linking: we don’t need to expose the source container, here the PostgreSQL database, to the network.

那么,链接容器实际上是做什么的呢?您已经了解到,链接允许源容器向接收容器提供有关其自身的信息。在我们的示例中,接收容器web可以访问有关源容器db的信息。为此,Docker在容器之间创建了一个安全隧道,不需要在容器外部暴露任何端口;当我们启动db容器时,我们没有使用-P或-P标识。这是链接的一大好处:我们不需要向网络暴露源容器,也就是示例中的PostgreSQL数据库。

Docker exposes connectivity information for the source container to the recipient container in two ways:

  • Environment variables,
  • Updating the /etc/hosts file.

Docker通过两种方式向接收容器暴露源容器的连接信息:

  • 环境变量
  • 正在更新/etc/hosts文件

Environment variables

环境变量

Docker creates several environment variables when you link containers. Docker automatically creates environment variables in the target container based on the --link parameters. It also exposes all environment variables originating from Docker from the source container. These include variables from:

Docker在链接容器时会创建多个环境变量。Docker根据–link参数自动在目标容器中创建环境变量。它还暴露了源容器中源自Docker的所有环境变量。其中包括以下变量:

  • the ENV commands in the source container’s Dockerfile
  • the -e, --env, and --env-file options on the docker run command when the source container is started
  • 源容器的Dockerfile中的ENV命令
  • 源容器启动时,docker run命令中的-e、-env和-env文件选项

These environment variables enable programmatic discovery from within the target container of information related to the source container.

这些环境变量可以在目标容器内对与源容器相关的信息中发现。

Warning

It is important to understand that all environment variables originating from Docker within a container are made available to any container that links to it. This could have serious security implications if sensitive data is stored in them.

一定要清楚的知道,容器中源自Docker的所有环境变量都可被任何链接它的容器获取。如果敏感数据存储在其中,这可能会产生严重的安全影响。

Docker sets an _NAME environment variable for each target container listed in the --link parameter. For example, if a new container called web is linked to a database container called db via --link db:webdb, then Docker creates a WEBDB_NAME=/web/webdb variable in the web container.

Docker为–link参数中列出的每个目标容器设置一个<alias>_NAME环境变量。例如,如果名为web的新容器通过–link db:webdb链接到名为db的数据库容器,则Docker会在web容器中创建一个WEBDB_NAME=/web/webdb变量。

Docker also defines a set of environment variables for each port exposed by the source container. Each variable has a unique prefix in the form <name>PORT<port>_<protocol>

Docker还为源容器暴露的每个端口定义了一组环境变量。每个变量都有一个唯一的前缀,格式为<name>PORT<PORT>_<protocol>。

The components in this prefix are:

  • the alias <name> specified in the --link parameter (for example, webdb)
  • the <port> number exposed
  • a <protocol> which is either TCP or UDP

此前缀中的组件包括:

  • 在 --link参数中指定的别名<name>(例如,webdb)
  • 暴露的<port>号
  • 一个<协议>,TCP或UDP

Docker uses this prefix format to define three distinct environment variables:

  • The prefix_ADDR variable contains the IP Address from the URL, for example WEBDB_PORT_5432_TCP_ADDR=172.17.0.82.
  • The prefix_PORT variable contains just the port number from the URL for example WEBDB_PORT_5432_TCP_PORT=5432.
  • The prefix_PROTO variable contains just the protocol from the URL for example WEBDB_PORT_5432_TCP_PROTO=tcp.

Docker使用这个前缀格式来定义三个不同的环境变量:

  • prefix_ADDR变量包含URL中的IP地址,例如WEBDB_PORT_5432_TCP_ADDR=172.17.0.82。
  • prefix_PORT变量仅包含URL的端口号,例如WEBDB_PORT_5432_TCP_PORT=5432。
  • prefix_PROTO变量仅包含URL中的协议,例如WEBDB_PORT_5432_TCP_PROTO=TCP。

If the container exposes multiple ports, an environment variable set is defined for each one. This means, for example, if a container exposes 4 ports that Docker creates 12 environment variables, 3 for each port.

如果容器暴露了多个端口,则为每个端口定义一个环境变量集。这意味着,例如,如果一个容器暴露了4个端口,Docker会创建12个环境变量,每个端口3个。

Additionally, Docker creates an environment variable called _PORT. This variable contains the URL of the source container’s first exposed port. The ‘first’ port is defined as the exposed port with the lowest number. For example, consider the WEBDB_PORT=tcp://172.17.0.82:5432 variable. If that port is used for both tcp and udp, then the tcp one is specified.

此外,Docker还创建了一个名为<alias>_PORT的环境变量。该变量包含源容器的第一个暴露端口的URL。“第一”端口被定义为编号最低的暴露端口。例如,考虑WEBDB_PORT=tcp://172.17.0.82:5432变量。如果该端口同时用于tcp和udp,则指定tcp端口。

Finally, Docker also exposes each Docker originated environment variable from the source container as an environment variable in the target. For each variable Docker creates an ENV variable in the target container. The variable’s value is set to the value Docker used when it started the source container.

最后,Docker还将源容器中每个源自Docker的环境变量公开为目标容器中的环境变量。对于每个变量,Docker在目标容器中创建一个<alias>_ENV_<name>变量。变量的值设置为Docker启动源容器时使用的值。

Returning back to our database example, you can run the env command to list the specified container’s environment variables.

回到我们的数据库示例,您可以运行env命令来列出指定容器的环境变量。

在这里插入图片描述
You can see that Docker has created a series of environment variables with useful information about the source db container. Each variable is prefixed with DB_, which is populated from the alias you specified above. If the alias were db1, the variables would be prefixed with DB1_. You can use these environment variables to configure your applications to connect to the database on the db container. The connection is secure and private; only the linked web container can communicate with the db container.

您可以看到Docker创建了一系列环境变量,其中包含有关源db容器的有用信息。每个变量都以DB_为前缀,DB_由您在上面指定的别名构成。如果别名是db1,则变量将以db1_为前缀。您可以使用这些环境变量,配置应用程序连接到db容器上的数据库。连接是安全和私有的;只有链接的web容器才能与db容器通信。

Important notes on Docker environment variables

Docker环境变量的重要注意事项

Unlike host entries in the /etc/hosts file, IP addresses stored in the environment variables are not automatically updated if the source container is restarted. We recommend using the host entries in /etc/hosts to resolve the IP address of linked containers.

不同于/etc/hosts文件中的主机条目,如果源容器重启,存储在环境变量中的IP地址不会自动更新。我们建议使用/etc/hosts中的主机条目来解析链接容器的IP地址。

These environment variables are only set for the first process in the container. Some daemons, such as sshd, scrub them when spawning shells for connection.

这些环境变量仅为容器中的第一个进程设置。某些守护进程(如sshd)在生成连接的shell时会对其进行清理。

Updating the /etc/hosts file

更新/etc/hosts文件

In addition to the environment variables, Docker adds a host entry for the source container to the /etc/hosts file. Here’s an entry for the web container:

除了环境变量之外,Docker还在/etc/hosts文件中添加了源容器的主机条目。以下是web容器的条目:

在这里插入图片描述
You can see two relevant host entries. The first is an entry for the web container that uses the Container ID as a host name. The second entry uses the link alias to reference the IP address of the db container. In addition to the alias you provide, the linked container’s name, if unique from the alias provided to the --link parameter, and the linked container’s hostname are also added to /etc/hosts for the linked container’s IP address. You can ping that host via any of these entries:

您可以看到两个相关的主机条目。第一个是使用container ID作为主机名的web容器的条目。第二个条目使用链接别名来引用db容器的IP地址。除了您提供的别名之外,链接容器的名称(如果与–link参数提供的别名不一致)和链接容器的主机名也会添加到/etc/hosts中,映射链接容器的IP地址。您可以通过这些条目中任何一种ping该主机:

在这里插入图片描述
Note

In the example, you had to install ping because it was not included in the container initially.

注意
在上述示例中,您必须安装ping,它最初是不包含在容器内的

Here, you used the ping command to ping the db container using its host entry, which resolves to 172.17.0.5. You can use this host entry to configure an application to make use of your db container.

在这里,您使用主机条目对db容器进行ping,该条目解析为172.17.0.5。您可以使用此主机条目来配置应用程序,以使用db容器。

Note

You can link multiple recipient containers to a single source. For example, you could have multiple (differently named) web containers attached to your db container.

注意
您可以将多个接收容器链接到一个源容器。例如,您可以将多个(不同名称的)web容器连接到db容器。

If you restart the source container, the /etc/hosts files on the linked containers are automatically updated with the source container’s new IP address, allowing linked communication to continue.

注意
如果重启源容器,那么链接容器上的/etc/hosts文件会自动更新为源容器的新IP地址,从而允许继续链接通信。

在这里插入图片描述

相关文章:

Docker 笔记(五)--链接

这篇笔记记录了Docker 的Link。 官方文档&#xff1a; Legacy container links - Communication across links 目录 参考Legacy container linksConnect using network port mappingConnect with the linking systemThe importance of naming Communication across linksEnviro…...

如何处理Android悬浮弹窗双击返回事件?

目录 1 前言 1.1 准备知识 1.2 问题概述 2 解决方案 3 代码部分 3.1 动态更新窗口焦点 3.2 窗口监听返回事件 3.3 判断焦点是否在窗口内部 3.4 窗口监听焦点移入/移出 4 注意事项 4.1 窗口范围 4.2 空隙处的返回事件处理 1 前言 1.1 准备知识 1&#xff09;开发环…...

高可用篇_A Docker容器化技术_II Docker环境搭建和常见命令

原创作者&#xff1a;田超凡&#xff08;程序员田宝宝&#xff09; 版权所有&#xff0c;引用请注明原作者&#xff0c;严禁复制转载 Docker安装 Docker 要求 CentOS7 系统的内核版本在 3.10以上 &#xff0c;查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。 …...

Vue.js+SpringBoot开发食品生产管理系统

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 加工厂管理模块2.2 客户管理模块2.3 食品管理模块2.4 生产销售订单管理模块2.5 系统管理模块2.6 其他管理模块 三、系统展示四、核心代码4.1 查询食品4.2 查询加工厂4.3 新增生产订单4.4 新增销售订单4.5 查询客户 五、…...

Python面试笔记

Python面试笔记 PythonQ. Python中可变数据类型与不可变数据类型&#xff0c;浅拷贝与深拷贝详解Q. 解释什么是lambda函数&#xff1f;它有什么好处&#xff1f;Q. 什么是装饰器&#xff1f;Q. 什么是Python的垃圾回收机制&#xff1f;Q. Python内置函数dir的用法&#xff1f;Q…...

springboot 查看和修改内置 tomcat 版本

解析Spring Boot父级依赖 去到项目的根pom文件中&#xff0c;找到parent依赖&#xff1a; <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>${springboot.version}…...

003——移植鸿蒙

目录 一、顶层Make分析 二、添加一个新的单板 2.1 Kconfig 2.2 Makefile 2.2.1 顶层Makefile 2.2.2 platform下的Makefile 2.2.3 platform下的bsp.mk文件 2.3 编译与调试 2.4 解决链接错误 三、内核启动流程的学习 3.1 韦东山老师总结的启动四步 3.2 启动文件分析…...

罗马数字转整数-力扣通过自己编译器编译

学会将力扣题目用自己自带的编译软件编译---纯自己想的本题解法 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如&#xff0c; 罗马数字 2 写做 II &#xff0c;即为两…...

深入解析JVM加载机制

一、背景 Java代码被编译器变成生成Class字节码&#xff0c;但字节码仅是一个特殊的二进制文件&#xff0c;无法直接使用。因此&#xff0c;都需要放到JVM系统中执行&#xff0c;将Class字节码文件放入到JVM的过程&#xff0c;简称类加载。 二、整体流程 三、阶段逻辑分析 3…...

python redis中blpop和lpop的区别

python redis中lpop()方法是获取并删除左边第一个对象。 def lpop(self,name: str,count: Optional[int] None,) -> Union[Awaitable[Union[str, List, None]], Union[str, List, None]]:"""Removes and returns the first elements of the list name.By de…...

第四百一十回

文章目录 1. 概念介绍2. 方法与细节2.1 获取方法2.2 使用细节 3. 示例代码4. 内容总结 我们在上一章回中介绍了"如何获取当前系统语言"相关的内容&#xff0c;本章回中将介绍如何获取时间戳.闲话休提&#xff0c;让我们一起Talk Flutter吧。 1. 概念介绍 我们在本章…...

程序员的README——编写可维护的代码(一)

用户行为不可预测&#xff0c;网络不可靠&#xff0c;事情总会出错。生产环境下的软件必须一直保持可用状态。 编写可维护的代码有助于你应对不可预见的情况&#xff0c;可维护的代码有内置的保护、诊断和控制。 切记通过安全和有弹性的编码实践进行防御式编程来保护你的系统&a…...

数据库管理-第160期 Oracle Vector DB AI-11(20240312)

数据库管理160期 2024-03-12 数据库管理-第160期 Oracle Vector DB & AI-11&#xff08;20240312&#xff09;1 向量的函数操作to_vector()将vector转换为标准值vector_norm()vector_dimension_count()vector_dimension_format() 2 将向量转换为字符串或CLOBvector_seriali…...

(C++进阶)boost库笔记

目录 1、boost::function 1.1 概述 1.2 boost包装器和C11包装器对比 1.2、代码示例 1、boost::function 1.1 概述 boost::function 是 Boost 库中提供的一个通用函数对象包装器&#xff0c;它可以存储指向任何可调用对象的指针&#xff0c;并且可以在任何时候通过 operat…...

MapReduce面试重点

文章目录 1. 简述MapReduce整个流程2. join原理 1. 简述MapReduce整个流程 数据划分(Input Splitting)&#xff1a;开始时&#xff0c;输入数据被分割成逻辑上的小块&#xff0c;每个块被称为Input Split。 映射(Map)&#xff1a;每个Input Split 由一个或多个Map任务处理&…...

C语言简单题(7)从主函数中输入10个等长字符串,用一个函数对他们排序,然后在主函数输出这10个已排好序的字符串

从主函数中输入10个等长字符串&#xff0c;用一个函数对他们排序&#xff0c;然后在主函数输出这10个已排好序的字符串 /* 从主函数中输入10个等长字符串&#xff0c;用一个函数对他们排序&#xff0c;然后在主函数输出这10个已排好序的字符串 */ #include<stdio.h> …...

光伏科普|太阳能光伏发电应用场景有哪些?

太阳能光伏发电的应用领域其实非常广泛&#xff0c;很多人会不相信&#xff0c;但在我们的日常生活中随处可见太阳能光伏产业&#xff0c;本文将详细介绍其应用场景有哪些。 一、工业领域厂房 太阳能光伏发电作为一种清洁、可再生的能源&#xff0c;安装在工业领域厂房&#…...

Go 构建高效的二叉搜索树联系簿

引言 树是一种重要的数据结构&#xff0c;而二叉搜索树&#xff08;BST&#xff09;则是树的一种常见形式。在本文中&#xff0c;我们将学习如何构建一个高效的二叉搜索树联系簿&#xff0c;以便快速插入、搜索和删除联系人信息。 介绍二叉搜索树 二叉搜索树是一种有序的二叉…...

基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的交通信号灯识别系统(深度学习+UI界面+训练数据集+Python代码)

摘要&#xff1a;本研究详细介绍了一种采用深度学习技术的交通信号灯识别系统&#xff0c;该系统集成了最新的YOLOv8算法&#xff0c;并与YOLOv7、YOLOv6、YOLOv5等早期算法进行了性能评估对比。该系统能够在各种媒介——包括图像、视频文件、实时视频流及批量文件中——准确地…...

以太坊开发学习-solidity(三)函数类型

目录 函数类型 函数类型 solidity官方文档里把函数归到数值类型 函数类型是一种表示函数的类型。可以将一个函数赋值给另一个函数类型的变量&#xff0c; 也可以将一个函数作为参数进行传递&#xff0c;还能在函数调用中返回函数类型变量。 函数类型有两类&#xff1a;- 内部&…...

教你把公司吃干抹净、榨干带走

大家好&#xff1a; 衷心希望各位点赞。 您的问题请留在评论区&#xff0c;我会及时回答 正文 打工人一定要做到够自私&#xff0c;把公司的一切为我所用&#xff0c;你要知道闷头打工是没有出路的。聪明的人会以最快的速度榨干带走公司的一切资源、人脉、技能&#xff0c;为…...

开发指南007-导出Excel

平台上开发导出Excel比过去的单体架构要复杂些&#xff0c;因为前端和后台不在一个进程空间里。 后台的操作是先生成excel文件&#xff0c;技术路线是jxl <dependency><groupId>net.sourceforge.jexcelapi</groupId><artifactId>jxl</artifactId&g…...

滑块验证码

1.这里针对滑块验证给了一个封装的组件verifition&#xff0c;使用直接可以调用 2.组件目录 3.每个文件的内容 3.1 Api文件中只有一个index.js文件&#xff0c;用来存放获取滑块和校验滑块结果的api import request from /router/axios//获取验证图片 export function reqGe…...

cmd常用指令

cmd全称Command Prompt&#xff0c;中文译为命令提示符。 命令提示符是在操作系统中&#xff0c;提示进行命令输入的一种工作提示符。 在不同的操作系统环境下&#xff0c;命令提示符各不相同。 在windows环境下&#xff0c;命令行程序为cmd.exe&#xff0c;是一个32位的命令…...

【嵌入式DIY实例】-DIY手势识别和颜色识别(基于APDS9960)

DIY手势识别和颜色识别(基于APDS9960) 文章目录 DIY手势识别和颜色识别(基于APDS9960)1、硬件准备2、APDS9960 手势识别传感器介绍3、硬件接线4、代码实现4.1 手势识别4.2 颜色识别4.3 趋近感应代码5、综合实例代码在本文中,我们将介绍 APDS9960 手势、RGB 和接近传感器与…...

python 直方图

python可以调用hist方法绘制直方图。 import matplotlib.pyplot as plt import numpy as np; plt.rcParams["font.family"]["SimHei"] # 确保图中中文字体正确显示 x[0.1,0.2,0.3,0.4,0.5,0.6,0.1,0.2,0.2,0.2] plt.xlabel(满意程度) plt.ylabel(频数) …...

如何在数据库中使用sql语言插入数据

在SQL中&#xff0c;你可以使用INSERT INTO语句来添加数据到数据库表中。以下是一个基本示例&#xff0c;说明如何向表中插入数据&#xff1a; 假设你有一个名为students的表&#xff0c;它有以下字段&#xff1a;id, name, age 和 grade。 CREATE TABLE students ( id INT P…...

JVM的双亲委派模型和垃圾回收机制

jvm的作用是解释执行java字节码.java的跨平台就是靠jvm实现的.下面看看一个java程序的执行流程. 1. jvm中的内存区域划分 jvm也是一个进程,进程在运行过程中,要行操作系统申请一些资源.这些内存空间就支撑了后续java程序的执行. jvm从系统申请了一大块内存,这块内存在java程序使…...

ThreadLocal-内存泄露问题

ThreadLocal概述 ThreadLocal是多线程中对于解决线程安全的一个操作类&#xff0c;它会为每个线程都分配一个独立的线程副本从而解决了变量并发访问冲突的问题。ThreadLocal 同时实现了线程内的资源共享案例&#xff1a;使用JDBC操作数据库时&#xff0c;会将每一个线程的Conn…...

ISIS默认层级实验简述

ISIS被划分为三个层级&#xff1a;Level 1、Level 2和Level 1-2。 默认情况下&#xff0c;ISIS路由器属于level 1-2,是指同时支持Level 1和Level 2的路由器。路由器既可以在同一个自治系统内部进行路由选择&#xff0c;也可以将路由信息传递到其他自治系统。 实验拓扑图&#…...

网络水果有哪些网站可以做/百度推广登录后台登录入口

apscheduler使用uWSGI的mule模块部署的时候报错&#xff0c; 因为系统时区和代码运行时区不一样导致。 解决办法&#xff1a;在初始化的时候指定上海的时区 scheduler BlockingScheduler(timezone"Asia/Shanghai") 转载于:https://www.cnblogs.com/duanzq/p/1127061…...

做百度网站排/上海seo外包

当 filter 不为 none 的时候&#xff0c;如果该元素或者其子元素具有 absolute 或 fixed 属性&#xff0c;那么它会为其创建一个新的包含块/容器&#xff0c;会造成该 absolute 或 fixed 元素的定位发生变化&#xff08;就是改变了 absolute 或 fixed 元素的定位 父 元素&#…...

asp.net 房产局政府网站模板/搜索引擎的四个组成部分及作用

因為網頁上有個欄位允許使用者輸入多行文字&#xff0c;可是如果只是單純的把該欄位直接跟Label Binding起來時&#xff0c;顯示出來的結果不會有換行的效果&#xff0c;只要改用自行繫結&#xff0c;然後用下面的方法&#xff0c;把輸出文字裡面的換行文字"\n"轉換成…...

正规网站建设定制/国内最开放的浏览器

转自量子位野生钢铁侠稚晖君在 GitHub 上开源了一个硬核项目。上次自制纯手工打造 AI 小电视&#xff0c;播放量就超过 300 万&#xff0c;还登上了 b 站首页。可能有些朋友对他还有点陌生。他毕业于电子科大生物医学工程&#xff0c;大学期间就自学计算机&#xff0c;现为 OPP…...

公司搜索seo/seo顾问服务公司

本节的目标是做一些优化以满足对应用对延迟的需求。这次需要几个步骤&#xff0c;包括完善Java堆大小的配置&#xff0c;评估垃圾回收占用的时间和频率&#xff0c;也许还要尝试切换到不同的垃圾回收器&#xff0c;以及由于使用了不同的垃圾回收器&#xff0c;需要重新优化Java…...

哪里有html企业网站模板下载/百度网盘手机app下载安装

$random函数调用时,返回一个32位的随机数,它是一个带符号的整形数。如下例&#xff1a; reg[23:0] rand; rand $random % 60; //产生一个在 -59~59 范围的随机数 reg[23:0] rand; rand {$random} % 60; //通过位拼接操作 {} 产生 0~59 范围的随机数 产生一个在 min, max 之间…...