asp
asp

Reputation: 835

apt-get not found in circleci pipeline (ubuntu)

Objective: Trying to get public ip of machine via circleci pipeline

Code I use:

version: 2.1
orbs:
  jq: circleci/[email protected]
executors:
  my-executor-terraform:
    docker:
      - image: docker.mirror.hashicorp.services/hashicorp/terraform:light
    working_directory: /home/circleci/workingfile
jobs:
  findpublicip:
    executor: my-executor-terraform
    steps:
      - checkout
      - run:
          name: get ip to add to azure storage account
          command: |
             apt-get install -y sudo
             sudo apt-get install curl
             ip=$(curl ifconfig.me)
             echo $ip
workflows:
  example-workflow:
    jobs:
      - findpublicip

Error I get:

#!/bin/sh -eo pipefail
apt-get install -y sudo
sudo apt-get install curl
ip=$(curl ifconfig.me)
echo $ip

/bin/sh: apt-get: not found

Exited with code exit status 127
CircleCI received exit code 127

VM that circleci uses:

Build-agent version 1.0.133815-bc3df9c1 (2022-07-26T23:08:57+0000)
System information:
 Server Version: 20.10.16
 Storage Driver: overlay2
  Backing Filesystem: xfs
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Kernel Version: 5.13.0-1023-aws
 Operating System: Ubuntu 20.04.4 LTS
 OSType: linux
 Architecture: x86_64

Starting container docker.mirror.hashicorp.services/hashicorp/terraform:light
  image is cached as docker.mirror.hashicorp.services/hashicorp/terraform:light, but refreshing...
light: Pulling from hashicorp/terraform
Digest: sha256:7cb0feb2b2c9839830a5be18f266d417bc4619f9eade9a326b019a0886c60a01
Status: Image is up to date for docker.mirror.hashicorp.services/hashicorp/terraform:light
docker.mirror.hashicorp.services/hashicorp/terraform:light:
  using image hashicorp/terraform@sha256:7cb0feb2b2c9839830a5be18f266d417bc4619f9eade9a326b019a0886c60a01
  pull stats: Image was already available so the image was not pulled
  time to create container: 627ms

Can you please help to find is missing here ? Circleci using ubuntu based vm to execute the workflow. I tried to install using apt-get but it says it dont find apt-get

Upvotes: 0

Views: 1139

Answers (1)

asp
asp

Reputation: 835

The solution was to use apk add curl instead of apt or apg-get because the runner vm is based on alpine docker image. Hope this helps others facing similar issue to make sure which type of linux flavour you were using

Upvotes: 1

Related Questions