title: Cannot create container for hyperledger service
body: <p>I have a docker-compose.yaml file defining 5 services:</p>
  
  <ul>
  <li>orderer.example.com</li>
  <li>peer0.org1.example.com</li>
  <li>peer1.org1.example.com</li>
  <li>peer0.org2.example.com</li>
  <li>peer1.org2.example.com</li>
  </ul>
  
  <p>Running the </p>
  
  <pre><code>docker-compose -f docker-compose.yaml up -d
  </code></pre>
  
  <p>command results in:</p>
  
  <pre><code>Creating network "hlf_byfn" with the default driver
  Creating peer1.org1.example.com ... 
  Creating peer0.org2.example.com ... 
  Creating peer1.org2.example.com ... 
  Creating orderer.example.com ... 
  Creating peer0.org1.example.com ... 
  Creating peer0.org2.example.com
  Creating peer1.org1.example.com
  Creating peer1.org2.example.com
  Creating orderer.example.com
  Creating orderer.example.com ... error
  
  ERROR: for orderer.example.com  Cannot create container for service orderer.example.com: Conflict. The container name "/orderer.example.com" is already in use by container "d6621116cf0d1ab108277893178ba29aCreating peer0.org1.example.com ... error
  
  ERROR: for peer0.org1.example.com  Cannot create container for service peer0.org1.example.com: Conflict. The container name "/peer0.org1.example.com" is already in use by container "185c6449d163fa5593001b3Creating peer0.org2.example.com ... done
  
  ERROR: for peer0.org1.example.com  Cannot create container for service peer0.org1.example.com: Conflict. The container name "/peer0.org1.example.com" is already in use by container "185c6449d163fa5593001b3bf9e052eee9ea365f89564a31fd84aac3c828bfbd". You have to remove (or rename) that container to be able to reuse that name.
  
  ERROR: for orderer.example.com  Cannot create container for service orderer.example.com: Conflict. The container name "/orderer.example.com" is already in use by container "d6621116cf0d1ab108277893178ba29a05d4e50b36143d33fb6ec1dfc472eeb8". You have to remove (or rename) that container to be able to reuse that name.
  ERROR: Encountered errors while bringing up the project.
  </code></pre>
  
  <p>So <em>orderer.example.com</em> and <em>peer0.org1.example.com</em> could not be created. 
  Output of <strong>docker ps</strong> :</p>
  
  <pre><code>CONTAINER ID        IMAGE                     COMMAND             CREATED              STATUS              PORTS                                              NAMES
  543b2bf5df5c        hyperledger/fabric-peer   "peer node start"   About a minute ago   Up About a minute   0.0.0.0:8051-&gt;7051/tcp, 0.0.0.0:8053-&gt;7053/tcp     peer1.org1.example.com
  1c652a838c3b        hyperledger/fabric-peer   "peer node start"   About a minute ago   Up About a minute   0.0.0.0:10051-&gt;7051/tcp, 0.0.0.0:10053-&gt;7053/tcp   peer1.org2.example.com
  65bdfcf71517        hyperledger/fabric-peer   "peer node start"   About a minute ago   Up About a minute   0.0.0.0:9051-&gt;7051/tcp, 0.0.0.0:9053-&gt;7053/tcp     peer0.org2.example.com
  </code></pre>
  
  <p><strong>docker-compose.yaml:</strong></p>
  
  <pre><code># Copyright IBM Corp. All Rights Reserved.
  #
  # SPDX-License-Identifier: Apache-2.0
  #
  
  version: '2'
  
  networks:
    byfn:
  
  services:
  
    orderer.example.com:
      extends:
        file:   base/docker-compose-base.yaml
        service: orderer.example.com
      container_name: orderer.example.com
      networks:
        - byfn
  
    peer0.org1.example.com:
      container_name: peer0.org1.example.com
      extends:
        file:  base/docker-compose-base.yaml
        service: peer0.org1.example.com
      networks:
        - byfn
  
    peer1.org1.example.com:
      container_name: peer1.org1.example.com
      extends:
        file:  base/docker-compose-base.yaml
        service: peer1.org1.example.com
      networks:
        - byfn
  
    peer0.org2.example.com:
      container_name: peer0.org2.example.com
      extends:
        file:  base/docker-compose-base.yaml
        service: peer0.org2.example.com
      networks:
        - byfn
  
    peer1.org2.example.com:
      container_name: peer1.org2.example.com
      extends:
        file:  base/docker-compose-base.yaml
        service: peer1.org2.example.com
      networks:
        - byfn
  
    cli:
      container_name: cli
      image: hyperledger/fabric-tools
      tty: true
      environment:
        - GOPATH=/opt/gopath
        - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
        - CORE_LOGGING_LEVEL=DEBUG
        - CORE_PEER_ID=cli
        - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
        - CORE_PEER_LOCALMSPID=Org1MSP
        - CORE_PEER_TLS_ENABLED=true
        - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
        - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
        - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
        - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
      working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
      volumes:
          - /var/run/:/host/var/run/
          - ./../chaincode/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
          - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
          - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
          - ./channel-artefacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artefacts
      depends_on:
        - orderer.example.com
        - peer0.org1.example.com
        - peer1.org1.example.com
        - peer0.org2.example.com
        - peer1.org2.example.com
      networks:
        - byfn
  </code></pre>
  
  <p>How can I determine, what went wrong, why the container name is in use already? </p>