This repository provides a comprehensive guide to install Docker and run the gem5 simulator within a Docker container. The guide is designed for complete beginners, offering detailed steps for setting up Docker and the gem5 simulator on Windows, macOS, and Ubuntu.
Docker is a platform that enables running applications in isolated containers, providing a consistent environment across different systems. The gem5 simulator is an open-source system simulator used for computer architecture research. In this guide, you'll learn how to use Docker to run gem5.
- No prior knowledge of Docker or gem5 is required.
- Ensure your computer has at least 4GB of RAM and enough storage for Docker images.
-
Download Docker Desktop:
- Visit the Docker Desktop for Windows download page and download the installer.
-
Install Docker Desktop:
- Double-click the downloaded installer to start the installation process.
- Follow the setup instructions, accepting the license agreement.
- Choose "Use WSL 2 instead of Hyper-V" for better performance. You may need to enable WSL 2 during installation.
- Restart your computer if prompted.
-
Start Docker Desktop:
- Once installed, Docker Desktop should start automatically. If not, find "Docker Desktop" in the Start Menu and launch it.
- Wait for Docker to initialize, which might take a few minutes.
-
Verify Docker Installation:
- Open Command Prompt (cmd) and run the following command:
docker --version
- Open Command Prompt (cmd) and run the following command:
-
Enable Docker Settings:
- Open Docker Desktop settings and allocate 2GB of memory for running gem5.
-
Download Docker Desktop:
- Navigate to the Docker Desktop for Mac download page and download the installer.
-
Install Docker Desktop:
- Open the downloaded
.dmgfile and drag the Docker icon to the Applications folder. - Launch Docker from the Applications folder.
- Follow the setup instructions, which may include enabling security settings in System Preferences.
- Open the downloaded
-
Verify Docker Installation:
- Open Terminal and run:
docker --version
- Open Terminal and run:
-
Configure Docker Settings:
- Open Docker Desktop, navigate to settings, and allocate 2GB of memory.
-
Update System Packages:
sudo apt update
-
Install Docker:
- Install Docker with the following command:
sudo apt install docker.io -y
- Install Docker with the following command:
-
Start and Enable Docker:
sudo systemctl start docker sudo systemctl enable docker -
Verify Docker Installation:
docker --version
-
Add Your User to the Docker Group:
- Run this command to use Docker without
sudo:sudo usermod -aG docker $USER - Log out and back in for the changes to take effect.
- Run this command to use Docker without
-
Create a Directory for gem5:
- On your host machine, create a directory to store gem5 files:
mkdir ~/gem5
- On your host machine, create a directory to store gem5 files:
-
Pull and Run the gem5 Docker Image:
- Use the following command to pull and run the pre-built Docker image for gem5:
docker run -tid --hostname=gem5_dev --name=gem5_container -v ~/gem5:/root ghcr.io/gem5/ubuntu-24.04_all-dependencies:v24-0 /bin/bash
- Use the following command to pull and run the pre-built Docker image for gem5:
-
Access the gem5 Container:
- Enter the Docker container with:
docker exec -ti gem5_container /bin/bash
- Enter the Docker container with:
-
Clone and Build gem5:
- Once inside the container, clone the gem5 repository:
git clone https://github.com/gem5/gem5.git cd gem5 scons build/X86/gem5.opt -j8
- Once inside the container, clone the gem5 repository:
-
Run a gem5 Simulation:
- To verify the setup, run a simple gem5 simulation:
build/X86/gem5.opt configs/learning_gem5/part1/simple.py
- To verify the setup, run a simple gem5 simulation:
By following these detailed steps, you have successfully installed Docker, set up a containerized environment, and configured gem5 within Docker. This setup ensures a consistent environment for exploring gem5 simulations.