carla icon indicating copy to clipboard operation
carla copied to clipboard

[Feature] CARLA DevContainer & Docker Improvements – Ubuntu 22.04

Open wambitz opened this issue 10 months ago • 6 comments

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


This change is Reviewable


Summary

This PR introduces two Docker-based approaches for building and running CARLA (version 0.9.15.2) on Ubuntu 22.04 (Jammy):

  1. Monolithic Docker Image – Fully self-contained build with Unreal Engine and CARLA.
  2. 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 (--monolith flag) vs. lightweight mode.
  • build_image.sh → Handles image creation, including Epic Games credential management for UE4 builds.

Updated Dockerfiles

  • carla.dockerfileLightweight mode (requires externally mounted UE4).
  • carla-ue4.dockerfileMonolithic mode (builds UE4 and CARLA in one image).

DevContainer Support (VS Code)

  • Adds .devcontainer/devcontainer.json for 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.

wambitz avatar Jan 31 '25 01:01 wambitz

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.

update-docs[bot] avatar Jan 31 '25 01:01 update-docs[bot]

Testing --monolith

image

wambitz avatar Jan 31 '25 02:01 wambitz

Testing devcontainer:

image

wambitz avatar Jan 31 '25 02:01 wambitz

The ability to build UE / CARLA from source mounted from the host is an improvement for developers!

qhaas avatar Apr 26 '25 23:04 qhaas

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 avatar May 15 '25 08:05 joel-mb

@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 monolith container and open CARLA with make launch-only

wambitz avatar May 26 '25 20:05 wambitz

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!!

wambitz avatar Jun 22 '25 21:06 wambitz

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!

joel-mb avatar Jun 23 '25 07:06 joel-mb

@wambitz Could you update your branch with ue4-dev?

joel-mb avatar Jun 23 '25 09:06 joel-mb

@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 avatar Jun 23 '25 23:06 wambitz

@wambitz Thanks again for the contribution! Merged!

joel-mb avatar Jun 25 '25 07:06 joel-mb

@wambitz Thanks again for the contribution! Merged!

Wonderful news @joel-mb!!! Thank you!

wambitz avatar Jun 26 '25 02:06 wambitz