Docker - issue command from one linked container to another
<p>I'm trying to set up a primitive CI/CD pipeline using 2 Docker containers -- I'll call them <strong>jenkins</strong> and <strong>node-app</strong>.  My aim is for the <strong>jenkins</strong> container to run a job upon commit to a GitHub repo (that's done).  That job should run a <code>deploy.sh</code> script on the <strong>node-app</strong> container.  Therefore, when a developer commits to GitHub, <strong>jenkins</strong> picks up the commit, then kicks off a job including automated tests (in the future) followed by a deployment on <strong>node-app</strong>.</p>

<p>The <strong>jenkins</strong> container is using the latest image (<a href="https://github.com/jenkinsci/docker/blob/83ce6f6070f1670563a00d0f61d04edd62b78f4f/Dockerfile" rel="nofollow">Dockerfile)</a>.</p>

<p>The <strong>node-app</strong> container's Dockerfile is:</p>

<pre><code>FROM node:latest
EXPOSE 80
WORKDIR /usr/src/final-exercise
ADD . /usr/src/final-exercise

RUN apt-get update -y
RUN apt-get install -y nodejs npm
RUN cd /src/final-exercise; npm install

CMD ["node", "/usr/src/final-exercise/app.js"]
</code></pre>

<p><strong>jenkins</strong> and <strong>node-app</strong> are linked using Docker Compose, and that <code>docker-compose.yml</code> file contains (updated, thanks to @alkis):</p>

<pre><code>node-app:
  container_name: node-app
  build: .
  ports:
   - 80:80
  links:
   - jenkins
jenkins:
  container_name: jenkins
  image: jenkins
  ports:
   - 8080:8080
  volumes:
   - /home/ec2-user/final-exercise:/var/jenkins
</code></pre>

<p>The containers are built using <code>docker-compose up -d</code> and start as expected.  <code>docker ps</code> yields (updated):</p>

<pre><code>CONTAINER ID        IMAGE                    COMMAND                  CREATED                 STATUS              PORTS                               NAMES
69e52b216d48        finalexercise_node-app   "node /usr/src/final-"   3 hours ago         Up 3 hours          0.0.0.0:80-&gt;80/tcp                  node-app
5f7e779e5fbd        jenkins                  "/bin/tini -- /usr/lo"   3 hours ago         Up 3 hours          0.0.0.0:8080-&gt;8080/tcp, 50000/tcp   jenkins
</code></pre>

<p>I can ping <strong>jenkins</strong> from <strong>node-app</strong> and vice versa.</p>

<p>Is this even possible?  If not, am I making an architectural mistake here?</p>

<p>Thank you very much in advance, I appreciate it!</p>

<p>EDIT:
I've stumbled upon <code>nsenter</code> and easily entering a container's shell using <a href="http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/" rel="nofollow">this</a> and <a href="http://www.sebastien-han.fr/blog/2014/01/27/access-a-container-without-ssh/" rel="nofollow">this</a>.  However, these both assume that the origin (in their case the host machine, in my case the <strong>jenkins</strong> container) has Docker installed in order to find the PID of the destination container.  I can <code>nsenter</code> into <strong>node-app</strong> from the host, but still no luck from <strong>jenkins</strong>.</p>