Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 11

Workflow fails when running steps in a container

Solved! Go to Solution.

I've just started setting up a workflow for one of my Elixir projects. I began with a simple workflow that just echos text in the shell. Here is that worklow:

 

name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: echo Hello, world!
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.

 

This workflow completes successfully.

 

Screen Shot 2019-08-21 at 3.24.13 PM.png

 

Next, I attempted to run the same commands inside a container with this workflow definition:

 

name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest
    
    container: elixir:1.6.2-alpine
    
    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: echo Hello, world!
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.

 

This workflow fails with the error `Error response from daemon: Container XXXXXX is not running`.

 

Screen Shot 2019-08-21 at 3.26.10 PM.png

 

I've just started to work with GitHub Actions, so maybe there is something I've overlooked. Can anyone help me resolve this issue? According to Workflow syntax for GitHub Actions, in the Container section: "A container to run any steps in a job that don't already specify a container." My assumption is that the container would be started and the steps would be run inside the Elixir Alpine Docker image.

10 Replies
Ground Controller Lvl 1
Message 2 of 11

Re: Workflow fails when running steps in a container

I'm having the exact same issue currently. Did you find a work around?

Copilot Lvl 2
Message 3 of 11

Re: Workflow fails when running steps in a container

I haven't figured out a solution yet. GitHub must be having issues because now the workflow isn't even running.

Copilot Lvl 2
Message 4 of 11

Re: Workflow fails when running steps in a container

I'm having the eact same one as well. 

Pilot Lvl 1
Message 5 of 11

Re: Workflow fails when running steps in a container

I have the same issue. It works when you use "-slim" images. Somehow, the alpine container is not detected as running.

Solution
Pilot Lvl 1
Message 6 of 11

Re: Workflow fails when running steps in a container

ci_1_9:
    name: Elixir 1.9 CI
    runs-on: ubuntu-latest

    container:
      # alpine causes errors in the steps, the container exits immediately, apparently
      image: elixir:1.9-slim
      env:
        MIX_ENV: test

    steps:
      - name: Checkout code
        uses: actions/checkout@master
      - name: Display build environment
        run: printenv
      - name: Install dependencies
        run: mix do local.hex --force, local.rebar --force, deps.get
      - name: Compile code (warnings as errors)
        run: mix compile --warnings-as-errors
      - name: Check code formatting
        run: mix format --check-formatted
      - name: Run tests (with coverage)
        run: mix test --cover
      - name: Create docs
        run: mix docs

  ci_1_9_alpine:
    name: Elixir 1.9 CI Alpine
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@master
      - name: Display build environment
        run: printenv
      - name: Install dependencies, compile, check formatting, test and create docs
        uses: docker://elixir:1.9-alpine
        env:
          MIX_ENV: test
        with:
          entrypoint: /bin/sh
          args: |
            -c "\
            mix do local.hex --force, local.rebar --force, deps.get && \
            mix compile --warnings-as-errors && \
            mix format --check-formatted && \
            mix test --cover && \
            mix docs"

Either of these work. I prefer the "slim" one, because in the alpine one (in this form) all commands get thrown together in one github actions step.

Copilot Lvl 3
Message 7 of 11

Re: Workflow fails when running steps in a container

This solved it for me too. Seems Alpine images has a bug in the runner.

Copilot Lvl 2
Message 8 of 11

Re: Workflow fails when running steps in a container

I had the same issue, i tried to look into what is happening a bit and it mounts tools from the host into the container and then overwrites the entrypoint with node to run setInterval to keep the container running.

--entrypoint "/__e/node12/bin/node" yourdockerimage -e "setInterval(function(){}, 24 * 60 * 60 * 1000);"

This is naturally a bad idea, as those binaries aren't compiled for alpine.

 

I also found some requirements on the Azure DevOps Site, which are prob. in effect for GitHub Actions too - but i didnt find a notice about this in the gh action docs:

Bash
glibc-based
Can run Node.js (which the agent provides)

Seems pretty overkill though, to have dependencies on glibc and nodejs just to run setInterval to keep the container running, there are better ways like for example: /bin/sh -c "tail -f /dev/null" or just by using sleep that do not have any dependencies and should also be usable everywhere where bash is available.

 

Sadly we can't affect the entrypoint / args passed to the main container, so the only possible way to workaround this is to either install glibc and all dependencies into the alpine image (not viable), or to not use container and define the image to use for every single command (bloats workflow up quite a bit).

 

Im working on a different workaround that i will share later.

Pilot Lvl 1
Message 9 of 11

Re: Workflow fails when running steps in a container

Kudos for the research :) it does seem weird that they don't just tail to dev/null to keep the container up, that's a pretty standard way of operating.

Copilot Lvl 3
Message 10 of 11

Re: Workflow fails when running steps in a container

I am actually working on making this exact change. In earlier versions, we were running actions such as git checkout by default, and they were written in JavaScript, so naturally we had a higher level of dependency on Node here. After shedding that, we now have legitimate scenarios like the ones described here that shouldn't need Node at all. Expect that update soon!