title: Install Portainer & Portainer Agent using docker-compose?
body: <p>I followed their doc <a href="https://portainer.readthedocs.io/en/stable/deployment.html#deploy-portainer-via-docker-compose" rel="nofollow noreferrer">here</a> to install portainer as shown below. But later on I got to know their file browser option only supported by portainer agent. So how can I add a portainer agent to my docker-compose.</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '2'
  
  services:
    portainer:
      image: portainer/portainer
      command: -H unix:///var/run/docker.sock
      restart: always
      ports:
        - 9000:9000
        - 8000:8000
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - portainer_data:/data
  
  volumes:
    portainer_data:
  </code></pre>
  <p>Note I found some <a href="https://github.com/portainer/portainer-compose/blob/master/docker-stack.yml" rel="nofollow noreferrer">instructions</a> as shown below but my project is a small project and I don't want to use docker stack or cluster. How can I install it purely using only docker-compose?</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.2'
  
  services:
    agent:
      image: portainer/agent
      environment:
        # REQUIRED: Should be equal to the service name prefixed by &quot;tasks.&quot; when
        # deployed inside an overlay network
        AGENT_CLUSTER_ADDR: tasks.agent
        # AGENT_PORT: 9001
        # LOG_LEVEL: debug
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /var/lib/docker/volumes:/var/lib/docker/volumes
      networks:
        - agent_network
      deploy:
        mode: global
        placement:
          constraints: [node.platform.os == linux]
  
    portainer:
      image: portainer/portainer
      command: -H tcp://tasks.agent:9001 --tlsskipverify
      ports:
        - &quot;9000:9000&quot;
        - &quot;8000:8000&quot;
      volumes:
        - portainer_data:/data
      networks:
        - agent_network
      deploy:
        mode: replicated
        replicas: 1
        placement:
          constraints: [node.role == manager]
  
  networks:
    agent_network:
      driver: overlay
  
  volumes:
    portainer_data:
  
  </code></pre>