pythongoogle-cloud-platformapt-getgoogle-cloud-workstations

Unable to locate package apt-get when building a custom Google Cloud Workstation image


I am trying to "build and push a modified workstations image to a container registry" as explained in this previous SO answer.

This is the Dockerfile that I am trying to use:

FROM us-central1-docker.pkg.dev/cloud-workstations-images/predefined/code-oss:latest

RUN \
  sudo apt-get update && \
  sudo apt-get install -y apache2 \
  sudo apt-get install -y libbz2-dev \
  sudo apt-get install -y php && \
  sudo apt-get install php-mysqli

When I try to build the image using docker build -t my-custom-image . I eventually receive this error:

E: Unable to locate package apt-get
E: Unable to locate package install
E: Unable to locate package apt-get
E: Unable to locate package install
The command '/bin/sh -c sudo apt-get update &&   sudo apt-get install -y apache2   sudo apt-get install -y libbz2-dev   sudo apt-get install -y php &&   sudo apt-get install php-mysqli' returned a non-zero code: 100

What am I doing wrong? Why can't I build this image?


Solution

  • I modified the Dockerfile to this and now it is working:

    FROM us-central1-docker.pkg.dev/cloud-workstations-images/predefined/code-oss:latest
    
    RUN \
      sudo apt-get update \
      && sudo apt-get install -y apache2 \
      && sudo apt-get install -y libbz2-dev \
      && sudo apt-get install -y php \
      && sudo apt-get install php-mysqli