title: How to use Deployer with Docker (Laradock)
body: <p>I created a fresh Digital Ocean server with Docker on it (using <a href="http://laradock.io" rel="nofollow noreferrer">Laradock</a>) and got my Laravel website working well.</p>
  
  <p>Now I want to automate my deployments using <a href="https://deployer.org" rel="nofollow noreferrer">Deployer</a>.</p>
  
  <p>I think my only problem is that I can't get Deployer to run <code>docker exec -it $(docker-compose ps -q php-fpm) bash;</code>, which is the command I successfully manually use to enter the appropriate Docker container (after using SSH to connect from my local machine to the Digital Ocean server).</p>
  
  <p>When Deployer tries to run it, I get this error message:</p>
  
  <pre><code>➤ Executing task execphpfpm
  [1.5.6.6] &gt; cd /root/laradock &amp;&amp; (pwd;)
  [1.5.6.6] &lt; /root/laradock
  [1.5.6.6] &gt; cd /root/laradock &amp;&amp; (docker exec -it $(docker-compose ps -q php-fpm) bash;)
  [1.5.6.6] &lt; the input device is not a TTY
  ➤ Executing task deploy:failed
  • done on [1.5.6.6]
  ✔ Ok [3ms]
  ➤ Executing task deploy:unlock
  [1.5.6.6] &gt; rm -f ~/daily/.dep/deploy.lock
  • done on [1.5.6.6]
  ✔ Ok [188ms]
  
  In Client.php line 99:
  
    [Deployer\Exception\RuntimeException (1)]
    The command "cd /root/laradock &amp;&amp; (docker exec -it $(docker-compose ps -q php-fpm) bash;)" failed.
  
    Exit Code: 1 (General error)
  
    Host Name: 1.5.6.6
  
    ================
    the input device is not a TTY
  </code></pre>
  
  <p>Here are the relevant parts of my <code>deploy.php</code>:</p>
  
  <pre><code>host('1.5.6.6')
          -&gt;user('root')
          -&gt;identityFile('~/.ssh/id_rsa2018-07-09')
          -&gt;forwardAgent(true)
          -&gt;stage('production')
          -&gt;set('deploy_path', '~/{{application}}');
  
  before('deploy:prepare', 'execphpfpm');
  
  task('execphpfpm', function () {
      cd('/root/laradock');
      run('pwd;');
      run('docker exec -it $(docker-compose ps -q php-fpm) bash;');
      run('pwd');
  });
  </code></pre>
  
  <p>I've already spent a day and a half reading countless articles and trying so many different variations. E.g. replacing the <code>-it</code> flag with <code>-i</code>, or setting <code>export COMPOSE_INTERACTIVE_NO_CLI=1</code> or replacing the whole <code>docker exec</code> command with <code>docker-compose exec php-fpm bash;</code>.</p>
  
  <p>I expect that I'm missing something fairly simple. Docker is widely used, and Deployer seems popular too.</p>