title: Github actions run steps in container
body: <p>Currently I am trying to implement a contianer into my Github Actions workflow. However I am having difficulties figuring out how to run steps in the container itself.</p>
  <p>The following workflow is used:</p>
  <pre class="lang-yaml prettyprint-override"><code>name: Laravel
  
  on: pull_request
  
  jobs:
    laravel-checks:
      runs-on: ubuntu-latest
      container: thomasowow/laravel-php:7.4
  
      steps:
      - uses: actions/checkout@v2
  
      - name: Yarn
        run: |
          yarn
  </code></pre>
  <p>This workflow results in the following error:</p>
  <pre><code>/__w/_temp/c399fe7d-6cd2-4cdc-bb06-acc829cddbb8.sh: 1: /__w/_temp/c399fe7d-6cd2-4cdc-bb06-acc829cddbb8.sh: yarn: not found
  ##[error]Process completed with exit code 127
  </code></pre>
  <p>It is unable to find <code>yarn</code>. The <code>thomasowow/laravel-php:7.4</code> runs locally with <code>yarn</code> available. I have tested this with other things that should be avilable in the docker image and they were not found either. It looks like the steps are not being executed in the container.</p>
  <p>The documentation <a href="https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer" rel="nofollow noreferrer">states the following</a> for the <code>jobs.&lt;job_id&gt;.container</code> syntax:</p>
  <blockquote>
  <p>A container to run any steps in a job that don't already specify a container</p>
  </blockquote>
  <p>I know there are solutions that work without using a container, I would prefer to use it.</p>
  <p>Anybody had the same issue or knows what I am doing wrong?</p>
  <hr />
  <h1>Solution</h1>
  <p>@DannyB pointed out that my image contains the following entrypoint:</p>
  <pre><code>[&quot;/bin/bash&quot;, &quot;--login&quot;, &quot;-c&quot;, &quot;tail -f /dev/null&quot;]
  </code></pre>
  <p>This might have been the cause of Github not being able to run things in the container properly.</p>
  <p>They were required in the image to install nvm, node and yarn</p>
  <pre><code>SHELL [&quot;/bin/bash&quot;, &quot;--login&quot;, &quot;-c&quot;]
  
  RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  RUN nvm install 12.18.3
  RUN npm install -g yarn
  
  CMD [&quot;/bin/bash&quot;]
  </code></pre>
  <p>Removing <code>SHELL</code> to <code>RUN npm ...</code> solved the issue and Github was able again to run things in the container properly.</p>
  <p>Currently I am still unable to install yarn without my old solution, but I think there are other ways to do this. Anybody suggestions how to do this in a clean way?</p>
  <hr />
  <h1>Installing node and yarn</h1>
  <p>I was able to get <code>node</code> and <code>yarn</code> installed using <a href="https://stackoverflow.com/a/57546198/1780996">this answer</a>.</p>
  <pre class="lang-yaml prettyprint-override"><code>ENV NODE_VERSION=12.18.3
  RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
  ENV NVM_DIR=/root/.nvm
  RUN . &quot;$NVM_DIR/nvm.sh&quot; &amp;&amp; nvm install ${NODE_VERSION}
  RUN . &quot;$NVM_DIR/nvm.sh&quot; &amp;&amp; nvm use v${NODE_VERSION}
  RUN . &quot;$NVM_DIR/nvm.sh&quot; &amp;&amp; nvm alias default v${NODE_VERSION}
  ENV PATH=&quot;/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}&quot;
  RUN npm install -g yarn
  </code></pre>
  <p>Some attempts were made to <code>COPY</code> from the office Node docker images. With this solution I was able to get <code>node</code> working. <code>npm</code> and <code>yarn</code> were also running but with errors.</p>
  <pre class="lang-yaml prettyprint-override"><code>COPY --from=node:12.18.3 /usr/local/bin/node /usr/bin/node
  ...
  </code></pre>