基于docker compose容器构建单个映像

时间:2017-11-25 11:15:54

标签: docker docker-compose

我的compose-yaml有3项服务 当我使用docker-compose时,我能够成功运行容器。 现在我想将这3个容器构建成单个图像。可能吗? 这是我的  的撰写-YAML

version: '2'

services:
  tomcat:
    container_name: tomcatcomposejdk
    build: .
    image: 'apexits/ubuntu-oracle-jdk8-tomcat9'
    ports:
      - "8787:8080"
      - "5003:5003"
    networks:
      b:
        ipv4_address: 10.5.0.6
    expose:
       - "8787"
       - "5003"

  mysql:
    container_name: mysqlcompose
    build: .
    image: 'mysql:5.6.36'
    ports:
      - "3306:3306"
    expose:
      - "3306"  
    networks:
      b:
        ipv4_address: 10.5.0.7
    environment:
      MYSQL_DATABASE: "bird251"
      MYSQL_ROOT_PASSWORD: "root"
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
    volumes:
      - ./BIRD251.sql:/tmp/BIRD251.sql
      - ./import.sh:/tmp/import.sh

  elasticsearch:
    container_name: escompose
    build: .
    image: 'elasticsearch:2.3.4'
    ports:
      - "9200:9200"
      - "9300:9300"
    expose:
      - "9200"
      - "9300"
    networks:
      b:
        ipv4_address: 10.5.0.8

networks:
  b:
    driver: bridge
    ipam:
     config:
       - subnet: 10.5.0.0/16
         gateway: 10.5.0.1

0 个答案:

没有答案