title: How to share volumes among containers by docker-compose
body: <p>My docker-compose defines two containers. I want one container shares a volume to the other container.</p>
  
  <pre><code>version: '3'
  services:
    web-server:
      env_file: .env
      container_name: web-server
      image: web-server
      build: 
        dockerfile: docker/Dockerfile
      ports: 
        - 3000:3000
        - 3500:3500
      volumes:
        - static-content: /workspace/static
      command: sh /workspace/start.sh
  
    backend-server:
      volumes:
        - static-content: /workspace/static
    volumes:
      static-content:
  </code></pre>
  
  <p>The above docker composer file declares two services, web-server and backend-server. And I declares the named volume <code>static-content</code> under services. I got below error when I run <code>docker-composer -f docker-composer.yml up</code>:</p>
  
  <pre><code>services.web-server.volumes contains an invalid type, it should be a string
  services.backend-server.volumes contains an invalid type, it should be a string
  </code></pre>
  
  <p>so how can I share volumes throw docker-composer?</p>