我应该如何创建一个

我应该如何创建一个

本文介绍了我应该如何创建一个 Dockerfile 以在一个实例中运行多个服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 Dockerfile.我是 Docker 新手.我正在创建这个 Dockerfile,它将在一个实例中启动 rabbitmq、ftp 服务器和 elasticsearch 服务器.我创建了这样的文件:

I'm trying to create a Dockerfile. I'm new to Docker. I'm creating this Dockerfile which shall start rabbitmq, ftp server and elasticsearch server in one instance. I have created the file like this :

# Pull base image
FROM alpine:latest
MAINTAINER Harshit Prasad

# define commonly used JAVA_HOME variable
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

# Expose the web interface ports
# 2121: ftp, a FTP server to be used for mass data / file storage
# 5672: rabbitmq, a rabbitmq message queue server to be used for global messages, queues and stacks
# 9300: elastic, an elasticsearch server or main cluster address for global database storage
EXPOSE 2121 5672 9300

# install Java
RUN
  echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections &&
  add-apt-repository -y ppa:webupd8team/java &&
  apt-get update &&
  apt-get install -y oracle-java8-installer &&
  rm -rf /var/lib/apt/lists/* &&
  rm -rf /var/cache/oracle-jdk8-installer

# install apache ftp server 1.1.0
RUN wget http://www-eu.apache.org/dist/mina/ftpserver/1.1.0/dist/apache-ftpserver-1.1.0.tar.gz
RUN tar xfz apache-ftpserver-1.1.0.tar.gz

# run ftp server
RUN cd apache-ftpserver-1.1.0 bin/ftpd.sh res/conf/ftpd-typical.xml

# install RabbitMQ server
RUN wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-generic-unix-3.6.6.tar.xz
RUN tar xf rabbitmq-server-generic-unix-3.6.6.tar.xz

# run the RabbitMQ server
RUN cd rabbitmq_server-3.6.6/sbin/rabbitmq-server

# install the management plugin to be able to use a web interface
RUN cd rabbitmq_server-3.6.6/sbin/rabbitmq-plugins enable rabbitmq_management

# install erlang programming language. RabbitMQ is written in erlang.
RUN apt-get install erlang

# elasticsearch service here

# set current working directory to yacy_grid_mcp
RUN git clone https://github.com/yacy/yacy_grid_mcp.git
WORKDIR /yacy_grid_mcp

我想知道我是否正确地创建了 Dockerfile.如果有人可以帮助我,那就太好了.另外请让我知道我应该如何继续添加弹性搜索服务.提前致谢!

I wanted to know if I'm creating Dockerfile correctly. It would be great if anyone can help me out. Also please let me know how should I proceed for adding elasticsearch service. Thanks in advance!

推荐答案

你不应该.

一个 docker 容器是不是一个完整的虚拟机来运行完整的应用程序实例和服务堆栈.

A docker container is not a full virtual machine to run a complete stack of application instances and services.

Docker 是应用程序虚拟化.这意味着单个容器运行单个进程.

Docker is application virtualization. That means a single container runs a single process.

在您的情况下,您需要 3 个容器.一个用于 RabbitMQ,一个用于您的 FTP 服务,一个用于弹性搜索.

In your case, you need 3 containers. One for RabbitMQ, one for your FTP service, one for elastic search.

您可能希望使用命名数据卷在 FTP 服务和读取它的任何内容之间共享文件系统.

You'll probably want to use named data volumes to share the file system between the FTP service and whatever reads it, as well.

一旦三个容器都工作了,就可以使用 docker-compose 来简化一起运行它们.

Once you have all three containers working, you can use docker-compose to simplify running them together.

这篇关于我应该如何创建一个 Dockerfile 以在一个实例中运行多个服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 22:24