Act: Run docker fails: docker: command not found

Created on 3 Sep 2020  ·  12Comments  ·  Source: nektos/act

When I try to run docker commands locally, it seems to fail.

name: test

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    name: Test Registry
    steps:
      - name: Checkout Action
        uses: actions/checkout@v2
      - name: Run local registry
        run: docker run -d -p 5000:5000 registry:2

Fails for

test/Pack Local Build] ⭐  Run Run local registry
| /github/workflow/1: line 2: docker: command not found
[test/Pack Local Build]   ❌  Failure - Run local registry

The same file works on Github Actions.

metstale

Most helpful comment

If you don't mind pulling the big docker image then, as the docs say, you can do:

act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

All 12 comments

This might sound silly but do you have docker installed on the machine you're running act on?
And if so can you run docker in a terminal and it works?

Yup, I do.

I run into the same issue

I got the same issue!

Same here

Got a hotfix for my problem.

I downgraded to docker/build-push-action@v1 in my action file. It worked!

 +++ uses: docker/build-push-action@v1
 --- uses: docker/build-push-action@v2

docker is not installed on node:12.6-buster-slim

 ~ docker exec -it 3d26c8ff7ec1 bash                                                                                                                                                                                    root@3d26c8ff7ec1:/# which docker
root@3d26c8ff7ec1:/# docker
bash: docker: command not found
root@3d26c8ff7ec1:/# dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                      Version                     Architecture Description
+++-=========================-===========================-============-========================================================================
ii  adduser                   3.118                       all          add and remove users and groups
ii  apt                       1.8.2                       amd64        commandline package manager
ii  base-files                10.3                        amd64        Debian base system miscellaneous files
ii  base-passwd               3.5.46                      amd64        Debian base system master password and group files
ii  bash                      5.0-4                       amd64        GNU Bourne Again SHell
ii  bsdutils                  1:2.33.1-0.1                amd64        basic utilities from 4.4BSD-Lite
ii  ca-certificates           20190110                    all          Common CA certificates
ii  coreutils                 8.30-3                      amd64        GNU core utilities
ii  curl                      7.64.0-4                    amd64        command line tool for transferring data with URL syntax
ii  dash                      0.5.10.2-5                  amd64        POSIX-compliant shell
ii  debconf                   1.5.71                      all          Debian configuration management system
ii  debian-archive-keyring    2019.1                      all          GnuPG archive keys of the Debian archive
ii  debianutils               4.8.6.1                     amd64        Miscellaneous utilities specific to Debian
ii  diffutils                 1:3.7-3                     amd64        File comparison utilities
ii  dirmngr                   2.2.12-1                    amd64        GNU privacy guard - network certificate management service
ii  dpkg                      1.19.7                      amd64        Debian package management system
ii  e2fsprogs                 1.44.5-1                    amd64        ext2/ext3/ext4 file system utilities
ii  fdisk                     2.33.1-0.1                  amd64        collection of partitioning utilities
ii  findutils                 4.6.0+git+20190209-2        amd64        utilities for finding files--find, xargs
ii  gcc-8-base:amd64          8.3.0-6                     amd64        GCC, the GNU Compiler Collection (base package)
ii  gnupg                     2.2.12-1                    all          GNU privacy guard - a free PGP replacement
ii  gnupg-l10n                2.2.12-1                    all          GNU privacy guard - localization files
ii  gnupg-utils               2.2.12-1                    amd64        GNU privacy guard - utility programs
ii  gpg                       2.2.12-1                    amd64        GNU Privacy Guard -- minimalist public key operations
ii  gpg-agent                 2.2.12-1                    amd64        GNU privacy guard - cryptographic agent
ii  gpg-wks-client            2.2.12-1                    amd64        GNU privacy guard - Web Key Service client
ii  gpg-wks-server            2.2.12-1                    amd64        GNU privacy guard - Web Key Service server
ii  gpgconf                   2.2.12-1                    amd64        GNU privacy guard - core configuration utilities
ii  gpgsm                     2.2.12-1                    amd64        GNU privacy guard - S/MIME version
ii  gpgv                      2.2.12-1                    amd64        GNU privacy guard - signature verification tool
ii  grep                      3.3-1                       amd64        GNU grep, egrep and fgrep
ii  gzip                      1.9-3                       amd64        GNU compression utilities
ii  hostname                  3.21                        amd64        utility to set/show the host name or domain name
ii  init-system-helpers       1.56+nmu1                   all          helper tools for all init systems
ii  libacl1:amd64             2.2.53-4                    amd64        access control list - shared library
ii  libapt-pkg5.0:amd64       1.8.2                       amd64        package management runtime library
ii  libassuan0:amd64          2.5.2-1                     amd64        IPC library for the GnuPG components
ii  libattr1:amd64            1:2.4.48-4                  amd64        extended attribute handling - shared library

I added a fake step:
apt-get update && apt-get install docker.io -y
and got it working, fair enough to test my action locally, you will need to remove that step before committing.

If you don't mind pulling the big docker image then, as the docs say, you can do:

act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

Issue is stale and will be closed in 7 days unless there is new activity

Would love there to be some intermediary image between node-slim and nektos/act-environments-ubuntu:18.04 that suffices for act, does anyone know of one?

Update: I made ghcr.io/artis3n/docker-node:latest

It has docker, node, npm, and yarn.
https://github.com/artis3n/docker-node

Am using it successfully in a private repo so I can't link:

act -j job -P ubuntu-latest=ghcr.io/artis3n/docker-node:latest

with a github action workflow step that looks like:

- name: The Thing
  uses: docker://theimageIwantToUse:version
  with:
    entrypoint: cmd
    args: args to the --cmd

Works great

Thanks for all the suggestions, and the smaller image @artis3n ! I'm going to close the issue, given the two valid options.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patoroco picture patoroco  ·  4Comments

lwille picture lwille  ·  4Comments

jclem picture jclem  ·  6Comments

bltavares picture bltavares  ·  5Comments

mheap picture mheap  ·  5Comments