Skip to main content

Build a docker container as your workspace.

Project description

DockerLab

Package Building Status pypi Image Building Status Docker

用Docker搭建你的工作区。


Read this in English.

环境要求

特点

  • 易于使用:只需几个命令即可构建和启动 Docker 容器。
  • 可定制:可以自定义要安装在容器中的 Docker 镜像和 Python 包。
  • 可重现:可以在不同的计算机上构建相同的 Docker 镜像。告别“这在我的机器上可以运行”的问题。
  • 方便:Dockerlab提供了一些方便的设置,包括工具和功能:
    • 工具:oh-my-zshdocker within dockertmuxlightvim
    • 解决权限问题:与主机相同的 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许可证

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.3.28.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

dockerlab-0.3.28-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file dockerlab-0.3.28.tar.gz.

File metadata

  • Download URL: dockerlab-0.3.28.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.16 Linux/6.5.0-1023-azure

File hashes

Hashes for dockerlab-0.3.28.tar.gz
Algorithm Hash digest
SHA256 e34b4b21a126831e7d00c82a34d7ae9b2c18692cfb0b4667e48cfafd57de189f
MD5 a343a4c37e918430cc6529ecc9ad1ef7
BLAKE2b-256 557e9ad540f0b9f955a5e1bb7f878128a188d1cfa78126cc48fac19d5cb9db84

See more details on using hashes here.

File details

Details for the file dockerlab-0.3.28-py3-none-any.whl.

File metadata

  • Download URL: dockerlab-0.3.28-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.16 Linux/6.5.0-1023-azure

File hashes

Hashes for dockerlab-0.3.28-py3-none-any.whl
Algorithm Hash digest
SHA256 601beb3f19a11fd0c06d4542229b77d20f15f99fb1fa2a5f6fcb037333dc4fe3
MD5 7d5def0ee223ce0e8680e517d0f37511
BLAKE2b-256 1a876fd67a269b1a3b312a01d58c26fed70eae90a73116b7950805aeef78be78

See more details on using hashes here.

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