# atmos devcontainer rebuild

Use this command to rebuild a devcontainer from scratch. This stops and removes the existing container, pulls the latest image, and creates a new container.

## Usage

```shell
atmos devcontainer rebuild <name> [flags]
```

## Arguments

- **`name`** — Name of the devcontainer to rebuild

## Flags

- **`--instance string`** — Instance name for this devcontainer (default: `default`)
- **`--attach`** — Attach to the container after rebuilding
- **`--no-pull`** — Don't pull the latest image before rebuilding

## Examples

```shell
# Rebuild a devcontainer
atmos devcontainer rebuild geodesic

# Rebuild and attach
atmos devcontainer rebuild geodesic --attach

# Rebuild without pulling latest image
atmos devcontainer rebuild geodesic --no-pull

# Rebuild a specific instance
atmos devcontainer rebuild terraform --instance project-a
```

## Behavior

1. Stops the container if it's running
2. Removes the existing container
3. Pulls the latest image (unless `--no-pull` is specified)
4. Creates a new container with the current configuration
5. Starts the new container
6. Optionally attaches to the container (if `--attach` is specified)

## Use Cases

- Configuration changes: After updating your `devcontainer.json` or `atmos.yaml`
- Image updates: To get the latest version of the base image
- Clean slate: When you want to start fresh without any accumulated state

## Try it out

### devcontainer-build

Copy the example into a new directory and make it your own:

```shell
atmos init examples/devcontainer-build
cd devcontainer-build
```

Requires a running Podman runtime (the example selects Podman) and network access for the image. The final commands clean up the local container.

```shell
atmos devcontainer rebuild geodesic
atmos devcontainer stop geodesic
atmos devcontainer remove geodesic
```

- [Installation guide](/install)
- [Explore the example](/examples/devcontainer-build)
- [Initialization and repository settings](/cli/commands/init#examples-and-source-directories)

## See Also

- [`atmos devcontainer start`](/cli/commands/devcontainer/start)
- [`atmos devcontainer remove`](/cli/commands/devcontainer/remove)
