Skip to content

Instantly share code, notes, and snippets.

@davins90
Last active August 12, 2023 15:12
Show Gist options
  • Save davins90/dfaec98741941155a0c468d34b52b0c0 to your computer and use it in GitHub Desktop.
Save davins90/dfaec98741941155a0c468d34b52b0c0 to your computer and use it in GitHub Desktop.
Docker images managed by Docker Compose with user permission (from root)

Setting Up JupyterLab in Docker on Ubuntu

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.

Prerequisites

  • 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.

Step-by-Step Guide

  1. 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

  2. Change the ownership to match your user ID and group ID (in this example, both are 1000). sudo chown -R 1000:1000 ./src

  3. Build the Docker Image: Navigate to the directory where your docker-compose.yml file is located and build the Docker image. docker-compose build

  4. Start the Services: Start the Docker containers. Use the -d option to run them in detached mode, freeing up your terminal. docker-compose up

  5. Verify the Containers are Running: Check the status of your containers. docker-compose ps

  6. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment