3种不同的应用程序和docker容器

2024-10-01 02:31:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我想先在Docker本地设置Kabana和Elastic Search,以显示本地不在Docker容器中的Python web应用程序的日志。不过,在服务器上,Python应用程序位于docker容器中。你知道吗

Kabana和Elastic Search还没有在服务器和本地设置。你知道吗

  • 有没有可能把卡巴纳和卡巴纳放在不同的码头集装箱里,还是应该放在一个集装箱里?更新:推荐哪个选项?

  • 如果只有一个,没有docker图像,Kabana和Elastic Search都存在,我该怎么办?

  • 他们能从我的pythonweb应用程序本地检索日志吗?它不在docker容器中,还是我必须把Python应用程序也放入容器中?如果是后者,它可以是单独的容器还是我应该把它放在与Kibana和elasticsearch相同的容器中?


Tags: docker图像服务器web应用程序search集装箱选项
2条回答

我会尽力回答你的问题:

  1. 是的,这是可能的,因为这个容器可以和另一个容器一起运行。你知道吗

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.

  1. 可以创建自定义图像。你知道吗

Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession. More -> https://docs.docker.com/engine/reference/builder/

  1. 你最好放在一个容器里,可以毫无问题地分开。你知道吗

为了更好地管理所有设置,我建议您查看Docker Compose。你知道吗

下面的示例说明了如何将两个容器链接起来:

elasticsearch:
  image: elasticsearch
  ports:
    - 9200:9200

kibana:
  image: kibana
  ports:
    - 5601:5601
  environment:
    - ELASTICSEARCH_URL=http://elasticsearch:9200
  links:
    - elasticsearch

简单的回答是:是的,你是自己的温顺,是的。你知道吗

Docker容器可以通过共享卷和网桥进行通信。 https://docs.docker.com/engine/userguide/containers/dockervolumes/https://docs.docker.com/engine/userguide/containers/networkingcontainers/

至于您的本地python应用程序,它取决于实现。如果要写入本地文件,那么卷是最好的方法。卷是映射到容器内路径的本地主机目录。你知道吗

如果您是通过网络协议进行的,那么您需要公开容器的端口,以便您的python应用程序可以访问它。你知道吗

现在,关于你的问题,有可能使你自己的形象。这是相当容易做到的。我将首先创建一个名为“Dockerfile”的文件,其中包含一个类似Ubuntu的基本图像

FROM ubuntu:14.04

然后我会添加install命令来安装所需的软件包

RUN apt-get update && apt-get install openjdk-7-jre
RUN apt-get install ... (etc)

实际上,您希望在Dockerfile中创建配置新安装的步骤 https://docs.docker.com/engine/userguide/containers/dockerimages/

相关问题 更多 >