title: docker host pid mode doesn't work in swarm mode
body: <p>I want a <code>container</code> to share <code>PID</code> namespace with host <code>OS</code> and I found <code>host PID mode</code> in <code>docker</code>.</p>
  
  <blockquote>
    <h2>pid</h2>
    
    <p><code>pid: "host"</code></p>
    
    <p>Sets the PID mode to the host PID mode. This turns on
    sharing between container and the host operating system the PID
    address space. Containers launched with this flag will be able to
    access and manipulate other containers in the bare-metal machine’s
    namespace and vise-versa.</p>
    
    <p>Referenced from <a href="https://docs.docker.com/compose/compose-file/#pid" rel="nofollow noreferrer">https://docs.docker.com/compose/compose-file/#pid</a></p>
  </blockquote>
  
  <p>It seems to work with <code>docker run</code> and <code>docker-compose up</code> but <code>swarm</code> mode, for example </p>
  
  <pre><code>$ docker run ---detach --pid=host ubuntu:16.04 tail -f /dev/null
  $ docker exec -it container_name top
  # Return all processes within host OS namespace.
  </code></pre>
  
  <hr>
  
  <pre><code>##docker-compose.yml##
  version: '3.4'
  
  services:
      test:
          image: ubuntu:16.04
          command: tail -f /dev/null
          pid: host
  </code></pre>
  
  <hr>
  
  <pre><code>$ docker-compose -f docker-compose.yml up -d
  $ docker exec -it container_name top
  # Return all processes within host OS namespace.
  </code></pre>
  
  <hr>
  
  <pre><code># there is only one manager node in the swarm(no another worker).
  
  $ docker stack deploy -c docker-compose.yml test
  $ docker exec -it container_name top 
  # Return only container process namespace.
  </code></pre>
  
  <p>I know some options could not work as to <code>swarm mode</code>. However, in such case, as I know, the docker document always specify that, for instance, <a href="https://docs.docker.com/compose/compose-file/#container_name" rel="nofollow noreferrer">container_name</a> option(See it is specifying that <code>container_name</code> won't work in <code>swarm</code> mode.).</p>
  
  <blockquote>
    <h2>container_name</h2>
    
    <p>.....</p>
    
    <p>.....</p>
    
    <p>Note: This option is ignored when deploying a stack in swarm mode with
    a (version 3) Compose file.</p>
  </blockquote>
  
  <p>My docker environment is <code>Docker 17.09.0-ce</code>, <code>docker-compose 1.17.0</code> on <code>Ubuntu16</code>. why doesn't <code>pid</code> mode work in <code>swarm</code> mode?</p>