apt not found when I use apt in gitlab ci before_script

fuzes picture fuzes · Mar 5, 2019 · Viewed 7.2k times · Source

I use gitlab ci to build docker image and I want to install python. When I build, the following is my gitlab-ci.yml:

image: docker:stable
stages:
  - test
  - build

before-script:
  - apt install -y python-dev python pip

test1:
  stage: test
  script:
  ...
    - pytest

build:
  stage: build
  - docker build -t $IMAGE_TAG .
  - docker push $IMAGE_TAG

but i got a Job failed

/bin/sh: eval: line : apt: not found
ERROR: Job failed: exit code 127

I also tried to apt-get install but the result is the same.

How do I install python??

Answer

Prabhat Singh picture Prabhat Singh · Mar 5, 2019

It's actually not a problem but you can say it featured by package-manager with Alpine you are using image: docker:stable or any such images like tomcat or Django they are on Alpine Linux. with minimal in the size .

image: docker:stable
stages:
 - test
 - build

before-script:
 - apk add python python-dev python pip

test1:
stage: test
script:
...
- pytest

build:
stage: build
 - docker build -t $IMAGE_TAG .
 - docker push $IMAGE_TAG

apk is Alpine Linux package management