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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dockerlab-0.3.29-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dockerlab-0.3.29.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.16 Linux/6.8.0-1021-azure

File hashes

Hashes for dockerlab-0.3.29.tar.gz
Algorithm Hash digest
SHA256 906757855c8004ad82d3ec95f5e5440b07a345c70b45777f1cdbd9e63b62da7a
MD5 ce60f3685b3ee0e5352241d5dac75b46
BLAKE2b-256 8f1c1a98c39e5af10778f4958db0850fa78c2ad1dd609959d1b24e8847bd0dd1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dockerlab-0.3.29-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.16 Linux/6.8.0-1021-azure

File hashes

Hashes for dockerlab-0.3.29-py3-none-any.whl
Algorithm Hash digest
SHA256 02c6f3339348a091e931891492eef42a5fd4804002cf3a6f6963fd315d35440b
MD5 1cc8ce5a26154b66c520e0579eccc4b1
BLAKE2b-256 54e6e931cc7469a79d500a2c77eff958b1381406ea0ba0ef2246943c9e68c185

See more details on using hashes here.

Supported by

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