Is it possible to use docker:dind, but using ubuntu instead of Alpine?

Viewed 22

I'm tyring to build and push a docker image to the container registry in Gitlab. I want to push an Ubuntu image based from a gitlab-ci.yml that I know works:

image: rocker/r-ver:latest

before_script:
   - apt-get update && apt-get upgrade -y
   - apt-get install tree curl gdebi-core -y
   - apt-get install -y --no-install-recommends libxt6
   - curl -LO https://quarto.org/download/latest/quarto-linux-amd64.deb
   - gdebi --non-interactive quarto-linux-amd64.deb
   - quarto install extension --no-prompt quarto-ext/grouped-tabsets
   - R -q -e 'install.packages(c("reticulate","vetiver","pins","dplyr","checkmate","quarto","gt","tidymodels"))'
   - R -q -e 'reticulate::install_miniconda()'
   - R -q -e 'reticulate::conda_create(envname = "sre-wiki", packages = c("python=3.8.13", "numpy"))'
   - R -q -e 'reticulate::conda_list()'
   - R -e 'write("reticulate::use_condaenv(\"sre-wiki\", required = TRUE)",file=file.path(R.home(),"etc","Rprofile.site"),append=TRUE)'
   - R -q -e 'reticulate::conda_install(envname = "sre-wiki", "vetiver", pip = TRUE)'

build image:
  image: docker
  services:
    - docker:20.10.10-dind
  script:
    - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY $CI_REGISTRY --password-stdin
    - docker build -t $CI_REGISTRY_IMAGE .
    - docker push $CI_REGISTRY_IMAGE

However I get the following because docker:dind by default uses alpine instead of Ubuntu.

/bin/sh: eval: line 128: apt-get: not found

I do not want to use alpine for various reasons, and want to stick with ubuntu. I can't seem ti find anywhere that suggests of to do this.

1 Answers

You can use a ubuntu image, then just install docker CLI in it.

To use the version of docker that ships with ubuntu's repos, you can do this:

myjob:
  #  ...
  image: "ubuntu"
  before_script:
    - apt update && apt install -y --no-install-recommends docker.io
    - ...

OR follow the install instructions from docker to use a specific version.

Alternatively, you can create your own ubuntu image that has docker installed, push it to a registry (like dockerhub or the gitlab registry), and use that as your image: instead.

Related