Skip to main content

DockerLab

Package Building Status pypi Image Building Status Docker

用Docker搭建你的工作区。


Read this in English.

环境要求

特点

  • 易于使用:只需几个命令即可构建和启动 Docker 容器。
  • 可定制:可以自定义要安装在容器中的 Docker 镜像和 Python 包。
  • 可重现:可以在不同的计算机上构建相同的 Docker 镜像。告别“这在我的机器上可以运行”的问题。
  • 方便:Dockerlab提供了一些方便的设置,包括工具和功能:
    • 工具:oh-my-zsh,docker within docker,tmux,lightvim
    • 解决权限问题:与主机相同的 uid 和 gid。
    • 将 $HOME 目录从容器反向挂载到主机
      • 轻松共享 ~/.ssh 和 ~/.gitconfig
      • 即使删除容器,配置文件也不会丢失,例如:zsh历史记录、配置文件、模型检查点等
    • 解决端口映射问题:与主机共享网络
  • 预构建镜像:Dockerlab提供了几个基本的预构建镜像,可快速设置工作区环境。

快速开始

1. 安装dockerlab

用pip安装dockerlab:

pip install dockerlab

或者从源码安装最新版本:

pip install git+https://github.com/hughplay/dockerlab.git

2. 设置dockerlab项目

创建一个新的dockerlab项目:

dockerlab new <project_name>

或者为现有项目初始化一个dockerlab环境:

dockerlab init .

这将设置一些文件和目录,其结构如下:

.
├── docker/
│   ├── Dockerfile
│   └── misc/
├── docker-compose.yml
├── docker.py
├── Makefile
└── .gitignore

3. 自定义工作环境

通常情况下,只需要修改docker/Dockerfile文件来自定义自己的工作环境。可能关心的文件:

  • docker/Dockerfile: 用于构建docker镜像的dockerfile。
  • docker-compose.yml: 用于构建docker容器的docker-compose文件。
  • docker.py: 用于构建和启动容器的python脚本。
  • Makefile: 基于make的便捷命令定义。

dockerlab准备了几个模板和预构建的docker镜像。可以通过运行以下命令将默认的docker/Dockerfile替换为需要的模板:

dockerlab use <template_name>

可用的模板可以通过 dockerlab ls列出,每个模板的详细信息可以在dockerlab/templates找到。

默认情况下,生成的docker/Dockerfile将使用预构建的docker镜像(如果存在)。也可以通过运行以下命令获取完整的dockerfile:

dockerlab use <template_name> --full

4. 构建和启动容器

make init

当你第一次执行上述命令时,它将要求你输入与容器相关的信息,并将它们存储在.env中。提示和输出示例如下:

# 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. 进入容器开启旅程

make in

本地Build镜像

docker build \
    -f dockerlab/templates/workspace_protein/Dockerfile \
    -t deepbase/dockerlab:workspace_protein \
    .

许可证

Dockerlab使用MIT许可证。

Metadata

Release files for dockerlab 0.3.29

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dockerlab 0.3.29
File Size Uploaded Provenance
dockerlab-0.3.29.tar.gz 19.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dockerlab 0.3.29
File Interpreter ABI Platform
dockerlab-0.3.29-py3-none-any.whl Python 3 none any Details

Total release size: 55.1 kB

Release files / dockerlab-0.3.29.tar.gz

Download URL dockerlab-0.3.29.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
906757855c8004ad82d3ec95f5e5440b07a345c70b45777f1cdbd9e63b62da7a
BLAKE2b-256 checksum
How to use checksums
8f1c1a98c39e5af10778f4958db0850fa78c2ad1dd609959d1b24e8847bd0dd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.16 Linux/6.8.0-1021-azure

Release files / dockerlab-0.3.29-py3-none-any.whl

Download URL dockerlab-0.3.29-py3-none-any.whl
Size 35.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02c6f3339348a091e931891492eef42a5fd4804002cf3a6f6963fd315d35440b
BLAKE2b-256 checksum
How to use checksums
54e6e931cc7469a79d500a2c77eff958b1381406ea0ba0ef2246943c9e68c185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.16 Linux/6.8.0-1021-azure

Security for dockerlab 0.3.29

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.3.29 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page