通过docker-compose up命令设置两次环境变量

时间:2019-03-06 19:08:06

标签: docker-compose corda

我在yaml文件中定义了环境变量JAVA_TOOL_OPTIONS。当我使用命令“ docker-compose -f up”启动容器时,出现以下错误:

拾起JAVA_TOOL_OPTIONS:-agentlib:jdwp = transport = dt_socket,地址= 8010,服务器= y,暂挂= n 在地址8010上监听传输dt_socket 捡起JAVA_TOOL_OPTIONS:-agentlib:jdwp = transport = dt_socket,地址= 8010,服务器= y,暂挂= n 错误:无法两次加载此JVM TI代理,请检查Java命令行中是否有重复的jdwp选项。 VM初始化期间发生错误 代理库无法初始化:jdwp

看起来JAVA_TOOL_OPTIONS设置了两次。任何帮助将不胜感激

下面是我的.yaml文件:

version: '3.1'
services:

  blumeglobal:
    build:
      context: .
      dockerfile: Dockerfile
    image: corda-3.2
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10003:10003"
      - "10004:10004"
      - "10005:10005"
    image: corda:3.2
    container_name: blumeglobal
    volumes:
      - ./build/nodes/BlumeGlobal/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/BlumeGlobal/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/BlumeGlobal/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/BlumeGlobal/node.conf:/opt/corda/node.conf
      - ./build/nodes/BlumeGlobal/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/BlumeGlobal/certificates/:/opt/corda/certificates/
    networks:
      - mynetwork

  bestbuy:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10012:10002"
      - "10013:10003"
      - "10014:10004"
      - "10015:10015"
    image: corda:3.2
    container_name: bestbuy
    volumes:
      - ./build/nodes/Bestbuy/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/Bestbuy/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/Bestbuy/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/Bestbuy/node.conf:/opt/corda/node.conf
      - ./build/nodes/Bestbuy/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/Bestbuy/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

  expeditors:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
      - JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8010,server=y,suspend=n
    ports:
      - "10022:10002"
      - "10023:10003"
      - "10024:10004"
      - "10025:10025"
      - "8010:8010"
    image: corda:3.2
    container_name: expeditors
    volumes:
      - ./build/nodes/Expeditors/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/Expeditors/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/Expeditors/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/Expeditors/node.conf:/opt/corda/node.conf
      - ./build/nodes/Expeditors/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/Expeditors/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

  motorcarrier:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10032:10002"
      - "10033:10003"
      - "10034:10004"
      - "10035:10035"
    image: corda:3.2
    container_name: motorcarrier
    volumes:
      - ./build/nodes/DTDC/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/DTDC/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/DTDC/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/DTDC/node.conf:/opt/corda/node.conf
      - ./build/nodes/DTDC/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/DTDC/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

  one:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10042:10002"
      - "10043:10003"
      - "10044:10004"
      - "10045:10045"
    image: corda:3.2
    container_name: one
    volumes:
      - ./build/nodes/ONE/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/ONE/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/ONE/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/ONE/node.conf:/opt/corda/node.conf
      - ./build/nodes/ONE/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/ONE/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

  cisco:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10052:10002"
      - "10053:10003"
      - "10054:10004"
      - "10055:10055"
    image: corda:3.2
    container_name: cisco
    volumes:
      - ./build/nodes/Cisco/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/Cisco/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/Cisco/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/Cisco/node.conf:/opt/corda/node.conf
      - ./build/nodes/Cisco/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/Cisco/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

  foxconn:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10062:10002"
      - "10063:10003"
      - "10064:10004"
      - "10065:10065"
    image: corda:3.2
    container_name: foxconn
    volumes:
      - ./build/nodes/Foxconn/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/Foxconn/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/Foxconn/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/Foxconn/node.conf:/opt/corda/node.conf
      - ./build/nodes/Foxconn/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/Foxconn/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

  toshiba:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - JAVA_OPTIONS=-Xmx512m
    ports:
      - "10072:10002"
      - "10073:10003"
      - "10074:10004"
      - "10075:10075"
    image: corda:3.2
    container_name: toshiba
    volumes:
      - ./build/nodes/Toshiba/network-parameters:/opt/corda/network-parameters
      - ./build/nodes/Toshiba/persistence.mv.db:/opt/corda/persistence.mv.db
      - ./build/nodes/Toshiba/additional-node-infos/:/opt/corda/additional-node-infos/
      - ./build/nodes/Toshiba/node.conf:/opt/corda/node.conf
      - ./build/nodes/Toshiba/cordapps/:/opt/corda/cordapps/
      - ./build/nodes/Toshiba/certificates/:/opt/corda/certificates/
    depends_on:
      - blumeglobal
    networks:
      - mynetwork

networks:
  mynetwork:
    external: true

下面是我的Dockerfile

FROM openjdk:8u151-jre-alpine

# Override default value with 'docker build --build-arg BUILDTIME_CORDA_VERSION=version'
# example: 'docker build --build-arg BUILDTIME_CORDA_VERSION=1.0.0 -t corda/node:1.0 .'
ARG BUILDTIME_CORDA_VERSION=3.2-corda
ARG BUILDTIME_JAVA_OPTIONS

ENV CORDA_VERSION=${BUILDTIME_CORDA_VERSION}
ENV JAVA_OPTIONS=${BUILDTIME_JAVA_OPTIONS}

# Set image labels
LABEL net.corda.version = ${CORDA_VERSION} \
      maintainer = "<blockchainservice@infosys.com>" \
      vendor = "infosys"

RUN apk upgrade --update && \
    apk add --update --no-cache bash iputils && \
    rm -rf /var/cache/apk/* && \
    # Add user to run the app && \
    addgroup corda && \
    adduser -G corda -D -s /bin/bash corda && \
    # Create /opt/corda directory && \
    mkdir -p /opt/corda/plugins && \
    mkdir -p /opt/corda/logs

# Copy corda jar
ADD --chown=corda:corda https://dl.bintray.com/r3/corda/net/corda/corda/${CORDA_VERSION}/corda-${CORDA_VERSION}.jar                       /opt/corda/corda.jar

COPY run-corda.sh /run-corda.sh
RUN chmod 777 /opt/corda && chmod +x /run-corda.sh && \
    sync && \
    chown -R corda:corda /opt/corda

# Expose port for corda (default is 10002) and RPC
EXPOSE 10002
EXPOSE 10003
EXPOSE 10004
EXPOSE 10005 10015 10025 10035 10045 10055 10065 10075

# Working directory for Corda
WORKDIR /opt/corda
ENV HOME=/opt/corda
USER corda

# Start it
CMD ["/run-corda.sh"]

1 个答案:

答案 0 :(得分:0)

为您的dockerfile尝试另一个基本的Java映像。 (例如'FROM azul / zulu-openjdk:8u192')

这是您要尝试执行的操作的一个示例,您可以在这里找到:https://github.com/EricMcEvoyR3/corda-docker-compose(您会注意到他甚至没有设置JAVA_TOOL_OPTIONS变量)

您还需要注意,Corda中有一个dockerform任务可以为您生成任务:https://docs.corda.net/docs/corda-os/4.4/generating-a-node.html#the-dockerform-task

您似乎正在复制dokcer撰写文件中的正确信息,只需再看看这些示例,看看是否能够使它正常工作。

在建设区块链的历险中运气最佳。