This guide will help you set up a test environment using Visual Studio Code (VSC) with a containerized environment. Follow these steps to build, start the container, and connect to it.
Make sure you have the following installed on your system:
- Docker
- Visual Studio Code
- Docker Extension for Visual Studio Code
- Remote - Containers Extension for Visual Studio Code
- Python Extension for Visual Studio Code
- Jupyter Extension for Visual Studio Code
- Open a terminal.
- Navigate to the
docker
directory of this repository:cd ./docker
- Build the Docker image by running the following command:
docker compose build
- In the terminal, ensure you are still in the
docker
directory. - Start the container by running:
docker compose up
- Open Visual Studio Code.
- Install the Docker, Remote - Containers, Python, and Jupyter extensions if you haven't already.
- Open the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
on Mac). - Type and select
Remote-Containers: Attach to Running Container...
. - You will see a list of running containers. Select your container from the list.
- Visual Studio Code will open a new window connected to your container. You can now work inside the container as if it were a local environment.
- In Visual Studio Code, navigate to the
src
directory. - Open the notebook file
cdf-example.ipynb
. - You can now run the cells in the notebook interactively within the container environment.
To stop the running container, you can either:
- In the terminal where you ran
docker compose up
, pressCtrl + C
. - Alternatively, you can stop the container using the Docker extension in Visual Studio Code:
- Click on the Docker icon in the Activity Bar.
- Under
Containers
, find your running container. - Right-click on the container and select
Stop
.
- Rebuilding the Image: If you make changes to the Dockerfile or any other files that affect the image, you will need to rebuild the image by running
docker compose build
again. - Logs and Debugging: You can view logs and debug the container using the Docker extension in Visual Studio Code or by running
docker compose logs
in the terminal.
For further information and troubleshooting, refer to the Docker and Visual Studio Code documentation.