如何使用docker容器为自定义代码配置git。

时间:2022-12-30 16:24:18

Sorry if I sound stupid with my question, I am newbie to docker. For one of my project, our provider has provided their docker images, docker-compose.yml.

对不起,如果我的问题听起来很愚蠢,我是码头工的新手。对于我的一个项目,我们的提供商提供了他们的docker镜像,docker-compose.yml。

In one of the container, there is a directory where we can place our custom files and folders. I would like to understand how can I configure git with this container so that can create branches and commit my code related to custom directory.

在其中一个容器中,有一个目录,我们可以放置自定义文件和文件夹。我想了解如何使用此容器配置git,以便可以创建分支并提交与自定义目录相关的代码。

Just one more thing if that can be helpful is with custom changes we are not modifying source image and this changes are synced up with the volumes mentioned in yml file. Thanks in advance for your time and help.

如果可能有用的话还有一件事是自定义更改,我们不会修改源映像,这些更改会与yml文件中提到的卷同步。在此先感谢您的时间和帮助。

1 个解决方案

#1


0  

I think there's some confusion here. The image you have can be used to test your code by simply mapping the folders.

我觉得这里有些混乱。您拥有的图像可以通过简单地映射文件夹来测试您的代码。

This means that if your git repository contains your code, you can use a mapping like:

这意味着如果您的git存储库包含您的代码,您可以使用如下映射:

volumes:
    - relative/path/to/my/code:/path/in/image

#1


0  

I think there's some confusion here. The image you have can be used to test your code by simply mapping the folders.

我觉得这里有些混乱。您拥有的图像可以通过简单地映射文件夹来测试您的代码。

This means that if your git repository contains your code, you can use a mapping like:

这意味着如果您的git存储库包含您的代码,您可以使用如下映射:

volumes:
    - relative/path/to/my/code:/path/in/image