Skip to content

Commit 2e014a5

Browse files
authored
Merge pull request #22233 from github/repo-sync
repo sync
2 parents 716fed6 + 3ff64a8 commit 2e014a5

File tree

15 files changed

+80
-21
lines changed

15 files changed

+80
-21
lines changed
16.5 KB
Loading
10.6 KB
Loading

components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/dotnet.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ const article: PlaygroundArticleT = {
213213
214214
Rebuilding inside your codespace ensures your changes work as expected before you commit the changes to the repository. If something does result in a failure, you’ll be placed in a codespace with a recovery container that you can rebuild from to keep adjusting your container.
215215
216+
You may occasionally want to perform a full rebuild to clear your cache and rebuild your container with fresh images. For more information, see "[Performing a full rebuild of a container](/codespaces/codespaces-reference/performing-a-full-rebuild-of-a-container)."
217+
216218
5. Check your changes were successfully applied by verifying the "Code Spell Checker" extension was installed.
217219
218220
![Extensions list](/assets/images/help/codespaces/dotnet-extensions.png)

components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/java.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ const article: PlaygroundArticleT = {
200200
![Rebuild container option](/assets/images/help/codespaces/codespaces-rebuild.png)
201201
202202
Rebuilding inside your codespace ensures your changes work as expected before you commit the changes to the repository. If something does result in a failure, you’ll be placed in a codespace with a recovery container that you can rebuild from to keep adjusting your container.
203+
204+
You may occasionally want to perform a full rebuild to clear your cache and rebuild your container with fresh images. For more information, see "[Performing a full rebuild of a container](/codespaces/codespaces-reference/performing-a-full-rebuild-of-a-container)."
203205
`,
204206
},
205207
{

components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/nodejs.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ const article: PlaygroundArticleT = {
199199
![Rebuild container option](/assets/images/help/codespaces/codespaces-rebuild.png)
200200
201201
Rebuilding inside your codespace ensures your changes work as expected before you commit the changes to the repository. If something does result in a failure, you’ll be placed in a codespace with a recovery container that you can rebuild from to keep adjusting your container.
202+
203+
You may occasionally want to perform a full rebuild to clear your cache and rebuild your container with fresh images. For more information, see "[Performing a full rebuild of a container](/codespaces/codespaces-reference/performing-a-full-rebuild-of-a-container)."
202204
`,
203205
},
204206
{

components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/python.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ const article: PlaygroundArticleT = {
215215
216216
Rebuilding inside your codespace ensures your changes work as expected before you commit the changes to the repository. If something does result in a failure, you’ll be placed in a codespace with a recovery container that you can rebuild from to keep adjusting your container.
217217
218+
You may occasionally want to perform a full rebuild to clear your cache and rebuild your container with fresh images. For more information, see "[Performing a full rebuild of a container](/codespaces/codespaces-reference/performing-a-full-rebuild-of-a-container)."
219+
218220
5. Check your changes were successfully applied by verifying the Code Spell Checker and Flask Snippet extensions were installed.
219221
220222
![Extensions list](/assets/images/help/codespaces/python-extensions.png)

content/codespaces/codespaces-reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ children:
1010
- /using-the-github-codespaces-plugin-for-jetbrains
1111
- /using-the-vs-code-command-palette-in-codespaces
1212
- /security-in-github-codespaces
13+
- /performing-a-full-rebuild-of-a-container
1314
- /disaster-recovery-for-github-codespaces
1415
---
1516

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Performing a full rebuild of a container
3+
intro: If you are low on disk space, or want to ensure your dev container configuration will work in new codespaces, you can perform a full rebuild of a container.
4+
versions:
5+
fpt: '*'
6+
ghec: '*'
7+
type: reference
8+
topics:
9+
- Codespaces
10+
shortTitle: Full rebuilds
11+
---
12+
13+
## About rebuilding a container
14+
15+
When you work in a codespace, your development environment is a Docker container that runs on a virtual machine. If you make changes to your dev container configuration from within a codespace, and you want to apply those changes to the current codespace, you need to rebuild the container.
16+
17+
By default, when you rebuild a container, {% data variables.product.prodname_github_codespaces %} will speed up the build process by reusing cached images from previous builds of the container. This is usually the quickest way to implement changes to your dev container configuration, for the following reasons.
18+
- {% data variables.product.prodname_github_codespaces %} can reuse images in your cache rather than repulling them from container registries.
19+
- The parts of your dev container configuration that define how the container is built, such as dev container features and Dockerfile instructions, may have already been implemented in image layers in your cache, so you won't need to wait for these processes to run again. (However, commands in your configuration that run after the container is built, such as `onCreateCommand`, will run again.)
20+
21+
Occasionally, you may want to perform a full rebuild of your container. With a full rebuild, {% data variables.product.prodname_github_codespaces %} cleans all Docker containers, images, and volumes from the cache, then rebuilds your container with newly pulled images. All the setup defined in your configuration will run again, generating new image layers. You may want to perform a full rebuild after many iterations of rebuilding your container with cached images, in situations such as the following.
22+
23+
- You want to ensure that the setup defined in your configuration is not dependent on cached images, and will run as required when someone creates a new codespace based on the configuration. For example, a dependency may have been removed from the base image since it was last pulled into your codespace.
24+
- You want to free up the disk space used by your cache, for example if you are low on disk space or want to minimize storage charges. Your image cache might be using a significant amount of disk space if you've changed your base image multiple times, if you've made a large number of iterative changes to your configuration, or if you're running multiple containers with Docker Compose.
25+
26+
## Performing a full rebuild
27+
28+
You can perform a full rebuild in {% data variables.product.prodname_vscode %}.
29+
30+
{% data reusables.codespaces.command-pallette %}
31+
1. Start typing "Rebuild" and select **Codespaces: Full Rebuild Container**.
32+
33+
![Screenshot of Full Rebuild Container command in the Command Pallette](/assets/images/help/codespaces/codespaces-rebuild-full.png)
34+
35+
## Persisting data over a full rebuild
36+
37+
Any files and folders contained in the `/workspaces` directory of your codespace are always persisted over a rebuild. You do not need to change any settings or add any configuration to retain the contents of this directory over a full rebuild.
38+
39+
If you want to preserve files outside the `/workspaces` directory over a full rebuild, you can create, at the desired location in the container, a symbolic link (symlink) to the persistent directory. For example, in your `/workspaces/.devcontainer` directory, you can create a `config` directory that will be preserved across a rebuild. You can then symlink the `config` directory and its contents as a `postCreateCommand` in your `devcontainer.json` file.
40+
41+
```json
42+
{
43+
"image": "mcr.microsoft.com/vscode/devcontainers/base:alpine",
44+
"postCreateCommand": ".devcontainer/postCreate.sh"
45+
}
46+
```
47+
48+
In the example `postCreate.sh` file below, the contents of the `config` directory are symbolically linked to the home directory.
49+
50+
```bash
51+
#!/bin/bash
52+
ln -sf $PWD/.devcontainer/config $HOME/config && set +x
53+
```
54+
55+
## Further reading
56+
- [Introduction to dev containers](/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)

content/codespaces/codespaces-reference/using-the-vs-code-command-palette-in-codespaces.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ To rebuild your container, [access the {% data variables.product.prodname_vscode
5858

5959
![Command to rebuild a codespace](/assets/images/help/codespaces/codespaces-rebuild.png)
6060

61+
{% data reusables.codespaces.full-rebuild-tip %}
62+
6163
### Codespaces logs
6264

6365
You can use the {% data variables.product.prodname_vscode_command_palette_shortname %} to access the codespace creation logs, or you can use it export all logs.

content/codespaces/developing-in-codespaces/the-codespace-lifecycle.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,9 @@ When a codespace times out, your data is preserved from the last time your chang
4040

4141
## Rebuilding a codespace
4242

43-
You can rebuild your codespace to restore a clean state as if you had created a new codespace. For most uses, you can create a new codespace as an alternative to rebuilding a codespace. You are most likely to rebuild a codespace to implement changes to your dev container configuration. When you rebuild a codespace, any Docker containers, images, volumes, and caches are cleaned, then the codespace is rebuilt.
43+
You can rebuild your codespace to implement changes to your dev container configuration. For most uses, you can create a new codespace as an alternative to rebuilding a codespace. By default, when you rebuild your codespace, {% data variables.product.prodname_github_codespaces %} will reuse images from your cache to speed up the rebuild process. Alternatively, you can perform a full rebuild, which clears your cache and rebuilds the container with fresh images.
4444

45-
If you need any of this data to persist over a rebuild, you can create, at the desired location in the container, a symbolic link (symlink) to the persistent directory. For example, in your `.devcontainer` directory, you can create a `config` directory that will be preserved across a rebuild. You can then symlink the `config` directory and its contents as a `postCreateCommand` in your `devcontainer.json` file.
46-
47-
```json
48-
{
49-
"image": "mcr.microsoft.com/vscode/devcontainers/base:alpine",
50-
"postCreateCommand": ".devcontainer/postCreate.sh"
51-
}
52-
```
53-
54-
In the example `postCreate.sh` file below, the contents of the `config` directory are symbolically linked to the home directory.
55-
56-
```bash
57-
#!/bin/bash
58-
ln -sf $PWD/.devcontainer/config $HOME/config && set +x
59-
```
60-
61-
For more information, see "[Introduction to dev containers](/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers#applying-configuration-changes-to-a-codespace)."
45+
For more information, see "[Introduction to dev containers](/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers#applying-configuration-changes-to-a-codespace)" and "[Performing a full rebuild of a container](/codespaces/codespaces-reference/performing-a-full-rebuild-of-a-container)."
6246

6347
## Stopping a codespace
6448

0 commit comments

Comments
 (0)