This guide outlines the steps to build and run a JupyterLab container with specific directories and permissions, following a common structure needed for data science projects.
- Docker and Docker Compose installed on an Ubuntu system.
- Your project should include a Dockerfile and docker-compose.yml file, as outlined earlier in the discussion.
-
Create the Source Directories: Create the src directory along with its subdirectories. These will be used as volumes in your Docker containers. mkdir -p ./src ./src/data_lake ./src/data_lake/input ./src/data_lake/output ./src/notebooks ./src/modules ./src/debug ./src/docs
-
Change the ownership to match your user ID and group ID (in this example, both are 1000). sudo chown -R 1000:1000 ./src
-
Build the Docker Image: Navigate to the directory where your docker-compose.yml file is located and build the Docker image. docker-compose build
-
Start the Services: Start the Docker containers. Use the -d option to run them in detached mode, freeing up your terminal. docker-compose up
-
Verify the Containers are Running: Check the status of your containers. docker-compose ps
-
Stop the Services (if needed): When you're done, you can stop the containers. docker-compose down
Notes
- This guide has been tested on Ubuntu and should work on similar Linux distributions.
- The UID and GID used (1000:1000) should match the user inside your Ubuntu system that will interact with the files in the src directory.
- Ensure that the paths in the docker-compose.yml file match the directory structure created in Step 1.
- By following these steps, you will have a JupyterLab environment running inside a Docker container with specific directories and permissions, allowing for smooth development and data handling in Ubuntu.