V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
newton108
V2EX  ›  Docker

如何 `git push` 到容器内?

  •  
  •   newton108 · 2017-03-04 00:33:34 +08:00 · 3383 次点击
    这是一个创建于 2604 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我现在希望在 host 里 git push, post-update hook 自动在容器里运行。

    如果 host 的 working dir 是 git clone hostpath/project.git/ 出来的, host 的 git 会,而不是容器里的 git 会,尝试 post-update hook

    我猜如果 git clone ssh://user@container/project.git 的话就会在容器内运行了。可是如何做到呢?

    第 1 条附言  ·  2017-03-04 07:35:17 +08:00
    最终换回 vagrant ……
    18 条回复    2017-03-04 22:34:31 +08:00
    shyling
        1
    shyling  
       2017-03-04 01:47:50 +08:00   ❤️ 1
    别这样做。。
    sneezry
        2
    sneezry  
       2017-03-04 02:03:32 +08:00 via iPhone   ❤️ 1
    别把数据和环境混到一起
    newton108
        3
    newton108  
    OP
       2017-03-04 02:44:57 +08:00
    @shyling
    @sneezry
    不懂,那怎么办?
    Docker 到底该怎么用?

    现在希望的工作流程是,在 host 里编辑 markdown , 在 docker 里 compile 成 html ,然后在 host 里浏览。
    bbx
        4
    bbx  
       2017-03-04 03:19:57 +08:00   ❤️ 1
    vagrant 就好了
    newton108
        5
    newton108  
    OP
       2017-03-04 03:29:18 +08:00
    @bbx 占空间太大了……
    bbx
        6
    bbx  
       2017-03-04 03:38:00 +08:00
    docker 也不小。。
    binux
        7
    binux  
       2017-03-04 03:47:38 +08:00
    mount volume
    newton108
        8
    newton108  
    OP
       2017-03-04 04:12:21 +08:00
    @binux 啥意思?这和 mount volume 有啥关系?
    binux
        9
    binux  
       2017-03-04 04:15:21 +08:00
    @newton108 #8 你把工作目录挂到 docker 里面,然后「 host 里编辑 markdown , 在 docker 里 compile 成 html ,然后在 host 里浏览」
    newton108
        10
    newton108  
    OP
       2017-03-04 05:34:29 +08:00
    @binux 这步我已经成功了,问题是如果我在 host 里 `git commit`, docker 里不会自动运行 hook, 这个 hook 不能在 host 里运行因为 host 是 mac ,容器是 linux 。
    binux
        11
    binux  
       2017-03-04 05:49:41 +08:00
    @newton108 #10 你不能写个脚本检测文件改动吗?
    bbx
        12
    bbx  
       2017-03-04 06:22:10 +08:00
    COPY GIT_REPO /DOCKER/PATH
    RUN mvn clean install
    RUN start_server.sh
    newton108
        13
    newton108  
    OP
       2017-03-04 06:23:05 +08:00
    @binux 没懂你什么意思。又不是所有的改动我都想 compile 。
    newton108
        14
    newton108  
    OP
       2017-03-04 06:25:11 +08:00
    @bbx 太高端了,等过两天好好研究。
    binux
        15
    binux  
       2017-03-04 06:29:58 +08:00
    @newton108 #13 你监控特定的文件啊,不知道 git 提交会改动哪个文件,最简单的, post-update 修改一个 commited 文件,你监控它不就好了。
    swulling
        16
    swulling  
       2017-03-04 08:41:23 +08:00 via iPhone
    难道标准流程不是 git.push 后触发构建,创建新的 image ,然后销毁旧的容器换新的
    just4test
        17
    just4test  
       2017-03-04 08:46:01 +08:00
    docker 的标准用法就是代码变更后重新创建 image 。
    你有两个选择:
    1.git push 之后重新构建重新运行
    2.使用第三方 Docker 托管,比如 Daocloud
    julyclyde
        18
    julyclyde  
       2017-03-04 22:34:31 +08:00
    不要把容器当虚拟机一样长期运行
    容器就是维护核心那一个进程的周边环境的东西
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1080 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:29 · PVG 07:29 · LAX 16:29 · JFK 19:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.