容器没有使用提到的dockerfile构建 - 多个容器

时间:2017-11-10 12:47:06

标签: mysql docker docker-compose

我正在处理一个案例,其中有一个主内核应用程序,使用 mysql Influxdb 作为数据库, grafana 用于显示数据图表。我正在使用<template> <!-- Sidebar --> <div class="ui right demo vertical sidebar labeled icon menu" id="mobile-sidebar"> <a class="item"> <i class="sticky note icon"></i> Bulletin </a> <a class="item"> <i class="newspaper icon"></i> News </a> <a class="item"> <i class="mail icon"></i> Contact us </a> </div> <div class="ui fixed inverted main menu mobile-menu"> <div class="ui container"> <div class="item"> Menu </div> <div class="right menu"> <a class="launch icon item" id="mobile-menu-trigger" v-on:click="toggle"> <i class="content icon"></i> </a> </div> </div> </div> <div class="pusher"> <h1> Hello Vue </h1> </div> </template> <script> export default { name: 'home', methods: { toggle: function () { $('#mobile-sidebar').sidebar('toggle') } } } </script> 和单个docker-compose为每个人创建单独的容器。

文件夹结构如下:

dockercompose

  • 搬运工-compose.yml
  • 内核
    • Dockerfilekernel
    • app.war
  • SQLDB
    • Dockerfilesqldb
    • dump.sql
    • startup.sh
  • grafana
    • Dockerfilegrafana
    • grafana.env
    • run.sh
  • tsdbdb
    • Dockerfiletsdb
    • Influxdb.env
    • init-influxdb.sh
    • entrypoint.sh

用于内核构建的容器,但在检查日志时,它显示了Influxdb的日志,与检查tsdbdb容器的日志时显示的日志相同。

Dockerfile的代码:

docker-compose
内核的

Dockerfile

version: '3'
services:
    mysqldb:
        build: 
            context: ./sqldb
            dockerfile: Dockerfilesqldb
        container_name: sql
        command: mysqld --user=root --verbose
        volumes:
        - ./sqldb:/app/sql
        restart: always
        expose:
        - "3306"
        ports:
        - "3306:3306"
        environment:
        - MYSQL_ROOT_PASSWORD=secretpassword
        - MYSQL_DATABASE=dbtest
        - MYSQL_USER=user
        - MYSQL_PASSWORD=password
        - MYSQL_ALLOW_EMPTY_PASSWORD=yes
    tsdbdb:
        build: 
            context: ./tsdbdb
            dockerfile: Dockerfiletsdb
        container_name: influx
        restart: always
        expose:
        - "8083"
        - "8086"
        ports:
        - "8083:8083"
        - "8086:8086"
        volumes:
        - ./tsdb:/app/tsdb
        env_file:
        - './tsdbdb/influxdb.env'
    grafana:
        build: 
            context: ./grafana
            dockerfile: Dockerfilegrafana
        container_name: grafana
        env_file:
        - './grafana/grafana.env'
        expose:
        - "3000"
        ports:
        - "3003:3000"
        links:
        - tsdbdb
    web:
        build: 
            context: ./kernel
            dockerfile: Dockerfilekernel
        container_name: kernel
        restart: always
        expose:
        - "8080"
        ports:
        - "8082:8080"
        depends_on:
        - mysqldb
        links:
        - tsdbdb
        - mysqldb
        volumes:
        - ./kernel:/app/kernel
潮流的

Dockerfile 以防万一

FROM java:openjdk-8-jre-alpine

ENV JHIPSTER_SLEEP 0

WORKDIR /app/kernel

# add directly the war
ADD *.war /app/kernel/app.war

RUN sh -c 'touch /app/kernel/app.war'
VOLUME /tmp

EXPOSE 8080

CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." && \
    sleep ${JHIPSTER_SLEEP} && \
    java -Djava.security.egd=file:/dev/./urandom -jar /app/kernel/app.war

这可能是由于一个愚蠢的错误而发生的,但我无法找到问题究竟在哪里。

1 个答案:

答案 0 :(得分:0)

所以我能够通过以下方式解决问题 -

将服务名称从 web 更改为内核,并在docker-compose.yml中为内核服务添加了命令行:

version: '3'
services:
    mysqldb:
        build: 
            context: ./sqldb
            dockerfile: Dockerfilesqldb
        container_name: sql
        command: mysqld --user=root --verbose
        # volumes:
        # - ./sqldb:/app/sql
        restart: always
        # expose:
        # - "3306"
        ports:
        - "3306:3306"
        environment:
        - MYSQL_ROOT_PASSWORD=secretpassword
        - MYSQL_DATABASE=dbtest
        - MYSQL_USER=user
        - MYSQL_PASSWORD=password
        - MYSQL_ALLOW_EMPTY_PASSWORD=yes
    tsdbdb:
        build: 
            context: ./tsdbdb
            dockerfile: Dockerfiletsdb
        container_name: influx
        restart: always
        # expose:
        # - "8083"
        # - "8086"
        ports:
        - "8083:8083"
        - "8086:8086"
        # volumes:
        # - ./tsdb:/app/tsdb
        env_file:
        - './tsdbdb/influxdb.env'
    grafana:
        build: 
            context: ./grafana
            dockerfile: Dockerfilegrafana
        container_name: grafana
        env_file:
        - './grafana/grafana.env'
        expose:
        - "3000"
        ports:
        - "3003:3000"
        links:
        - tsdbdb
    kernel:
        build: 
            context: ./kernel
            dockerfile: Dockerfilekernel
        container_name: kernel
        command: java -Djava.security.egd=file:/dev/./urandom -jar /app/kernel/app.war
        restart: always
        # expose:
        # - "8080"
        ports:
        - "8082:8080"
        links:
        - tsdbdb
        - mysqldb
        # volumes:
        # - ./kernel:/app/kernel

虽然我不确定为什么只添加命令解决了这个问题。