Skip to main content

Build a docker container as your workspace.

Project description

DockerLab

Dockerlab Docker

Build a docker container as your workspace.


Pre-requirements

Features

  • Easy to use: Just a few commands to build and start a docker container.
  • Customizable: You can customize the docker image and the python packages you want to install in the container.
  • Reproducible: You can build the same docker image on different machines. Say bye bye to the It works on my machine problem.
  • Convenient: We made some convenient setups for you, including tools and functions:
    • miniconda
    • oh-my-zsh
    • run docker within docker
    • make the user have the same uid and gid as the host (prevent permission problems)
    • mount the home of the container to the host (by hacking)
      • easy to share ~/.ssh and ~/.gitconfig
      • files will not be lost even if the container is removed
        • zsh history
        • configuration files
        • model checkpoints
        • etc.
    • sharing network with the host (no need extra port mapping)
    • (optional) tmux
    • (optional) lightvim

Quick Start

1. Install dockerlab

pip install dockerlab

2. Setup a dockerlab project

Create a new dockerlab project:

dockerlab new <project_name>

Or init a dockerlab project in the current directory:

dockerlab init .

This will setup a few files and directories, the structure is as follows:

.
├── docker
│   ├── Dockerfile
│   ├── Dockerfile.full
│   ├── misc
│      ├── init_workspace
│      ├── sources.list.ubuntu18.04
│      └── sources.list.ubuntu20.04
│   └── requirements.txt
├── docker-compose.yml
└── docker.py

3. DIY your own workspace environment

In general, you only need to modify docker/Dockerfile and requirements.txt to customize your own workspace environment. Files you may care about:

  • docker/Dockerfile: The dockerfile for building the docker image.
  • requirements.txt: The python packages you want to install in the container.
  • docker-compose.yml: The docker-compose file for building the docker container.
  • docker.py: The python script for building and starting the container.

4. Build and start the container

python docker.py startd

When you first execute the above command, it will ask you to enter information related to the container and store them in .env. The example of prompt and the output are as follows:

# prompts
Give a project name [dockerlab]: dockerlab
Code root to be mounted at /project [.]:
Data root to be mounted at /data [data]:
`/home/hongxin/code/dockerlab/data` does not exist in your machine. Create? [yes]:
Log root to be mounted at /log [log]:
`/home/hongxin/code/dockerlab/log` does not exist in your machine. Create? [yes]:
directory to be mounted to hongxin [./docker/misc/container_home]:
`/home/hongxin/code/dockerlab/container_home` does not exist in your machine. Create? [yes]:

# output
Your setting (.env):
  UID: 1000
  GID: 1000
  USER_NAME: hongxin
  PROJECT: dockerlab
  CODE_ROOT: .
  DATA_ROOT: /home/hongxin/code/dockerlab/data
  LOG_ROOT: /home/hongxin/code/dockerlab/log
  CONTAINER_HOME: /home/hongxin/code/dockerlab/container_home
  COMPOSE_PROJECT_NAME: dockerlab_hongxin

5. Get in the container and start your journey.

python docker.py

License

DockerLab is released under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockerlab-0.2.6.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distribution

dockerlab-0.2.6-py3-none-any.whl (14.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page