carla
carla copied to clipboard
[Feature] CARLA DevContainer & Docker Improvements – Ubuntu 22.04
Description
Detailed documentation at: Docs/build_docker_ubuntu22.md
Fixes
- Update Docker support to Ubuntu 22.04 image
- Add support for devcontainers
Where has this been tested?
- Platform(s): Ubuntu 24.04 64 bit (Host) / Ubuntu 22.04 (Docker Image)
- Python version(s): 3.10
- Unreal Engine version(s): 4.26
Possible Drawbacks
Backward compatibility with Python 2.7
Summary
This PR introduces two Docker-based approaches for building and running CARLA (version 0.9.15.2) on Ubuntu 22.04 (Jammy):
- Monolithic Docker Image – Fully self-contained build with Unreal Engine and CARLA.
- Lightweight DevContainer – Uses an external, locally compiled Unreal Engine folder for faster and leaner development.
This setup improves developer experience by enabling a VS Code DevContainer workflow and optimizing build processes for both Docker modes.
Key Features
New Docker Approaches
- Monolithic (Self-contained)
- Bundles Unreal Engine 4.26 and CARLA into a single Docker image.
- Simplifies setup but requires significant build time (~100GB+ image).
- Lightweight DevContainer
- Uses an existing local Unreal Engine build to compile CARLA inside a leaner container.
- Reduces Docker image size and dramatically speeds up development.
Scripts for Easy Setup
run_container.sh→ Detects monolithic (--monolithflag) vs. lightweight mode.build_image.sh→ Handles image creation, including Epic Games credential management for UE4 builds.
Updated Dockerfiles
carla.dockerfile→ Lightweight mode (requires externally mounted UE4).carla-ue4.dockerfile→ Monolithic mode (builds UE4 and CARLA in one image).
DevContainer Support (VS Code)
- Adds
.devcontainer/devcontainer.jsonfor easy development inside VS Code. - Enables NVIDIA GPU passthrough for CARLA simulation in containerized environments.
How to Use
Lightweight Mode (Faster)
export UE4_ROOT=/absolute/path/to/UnrealEngine_4.26 # Use an existing Unreal Engine build
./Scripts/run_container.sh # Starts container
make PythonAPI && make CarlaUE4Editor # Build inside the container
Monolithic Mode (Self-contained)
echo "EPIC_USER=username" >> .env # Add Epic Games credentials
echo "EPIC_PASS=your_github_token" >> .env
./Scripts/run_container.sh --monolith # Builds full image with UE4 + CARLA
Known Issues
- Disk Space: The monolithic image exceeds 100GB. Ensure you have sufficient storage.
- Backward Compatibility: Changes are untested with Python 2.7.
- UE4 Setup Required: Lightweight mode requires a precompiled Unreal Engine on the host.
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.
Testing --monolith
Testing devcontainer:
The ability to build UE / CARLA from source mounted from the host is an improvement for developers!
Hi @wambitz ! Thanks for this contribution and sorry for the late reply. I think this is a valuable addition to the community, as it facilitates working with CARLA from source on Linux. I’ll leave some minor comments, but overall the PR looks good.
@joel-mb I made the appropriate changes, I went through the instructions and I made a few modifications to improve the reading flow, also I catch a small mounting "bug", the scripts were not mounting in the same directory as when using the devcontainer from VS Code. If fixed that so now it doesn't matter where you build from, either opening the container with the scripts or from VS Code devcontainer.
I tested these 3 options:
- Launched container from scripts and open CARLA with
make launch - Launched container from VS Code and open CARLA with 'make launch`
- Launch from
monolithcontainer and open CARLA withmake launch-only
Hi @joel-mb, I'm just following-up here.
Is there something else I should address or is there any update from your side? Should I resolve the conversations?
Thanks!!
Hi @wambitz,
I've resolved all the conversations. The PR is ready to be merged. We'll wait for this PR to be merged: https://github.com/carla-simulator/carla/pull/8996. After that, update your branch with ue4-dev. This will trigger the CI/CD, and we’ll be good to go.
Thanks!
@wambitz Could you update your branch with ue4-dev?
@wambitz Could you update your branch with
ue4-dev?
Hi @joel-mb, I just did, I didn't get a chance last night, thank you for your prompt reply! :raised_hands:
@wambitz Thanks again for the contribution! Merged!
@wambitz Thanks again for the contribution! Merged!
Wonderful news @joel-mb!!! Thank you!