If you don't specify a Docker image, Space will use the default one. The default image is based on Ubuntu OS and includes Git, curl, Docker, Docker Compose, Kubernetes, Google Cloud support, Open JDK, Python, PHP, .NET SDK, Ruby, Go, Node.js, npm, yarn, and other tools.
You can use this Dockerfile as a basis for creating your own image and hosting it in Space Packages. Learn more
Specify an image for the dev environment
A dev environment runs in a Docker container. If you don't specify an image in a devfile.yaml, Space will use the default image. As a custom image, you can use an image from Docker Hub (or other registries that doesn't require authentication), Space Packages, or create an image from Dockerfile each time a user creates a new dev environment. To specify the image, use the project's devfile.
OS: any glibc-based Linux distribution (for example, CentOS 7+, Debian 9+, Ubuntu 20.04+).
Tools: Git, OpenSSH (if you want to use a remote Git repository), lsof (if you need port forwarding in the IDE).
The container must run as root (there must be no non-root users in Dockerfile).
Container image vs warm-up snapshot
In some cases, you might face a dilemma where to put a certain preparation step: to the container image or to the environment warm-up? For example, your project requires an SDK. To get the SDK, you run curl - o sdk.zip $SDK_URL && unzip sdk.zip. Where do you put this line: to the Dockerfile or to the warm-up script?
All additional tools (e.g., the tools installed with apt get) should be installed to the dev environment's image, i.e., described in the Dockerfile.
All binary dependencies stored within the root or the project directory should go to a warm-up script. So, in the example above, the best solution would be to get the SDK in a warm-up script.
In the components.container.image parameter, specify the full image URL.
Important: the Space Packages registry must either belong to the same project where you configure a dev environment or be attached to this project.
A dev environment can use a custom Dockerfile for its container image. The Dockerfile can be located anywhere in the project repository. Note that in this case, Space will build the image each time a user creates a new dev environment. To reduce startup time of the dev environment, we recommend that you build the image once and publish it to the project's Space Packages registry.
Open the project source code and create a Dockerfile, for example, in the docker directory.
Edit the Dockerfile to configure the image.
For example, an image for a Java project:
RUN apt-get update
RUN apt-get install -y \
&& rm -rf /var/lib/apt/lists/*
Open the project source code and open the project's devfile. If it doesn't exist, create a new one, for example, .space/devfile.yaml.
In the devfile, specify the path to a Dockerfile (uri) and, optionally, to the Docker context (buildContext). You must specify both paths relative to the projectRoot. For example:
- name: image-build
# (Optional) path to Docker context relative to projectRoot
# by default, projectRoot is repository root
# (Required) path to Dockerfile relative to projectRoot
Commit and push the changes.
You can use images not only from Docker Hub but from any public registry that doesn't require authentication. In case of an image from Docker Hub, you can specify only the image name. For other registries, you must specify the full image URL.