问题描述
在主机上,我可以使用以下方式创建第二个用户: admin
和 push
到该用户的git文件夹:
On my host machine, I'm able to create a second user: admin
and push
to that user's git folder using:
admin @ localhost:folder
当我创建一个托管git服务器的Docker容器时,在暴露了 port 22
后,如何从本地计算机向 localhost:22
git push code>哪个是集装箱港口的位置?
When I create a Docker container hosting a git server, after exposing port 22
how do I git push
from my local machine to localhost:22
which would be the location of the container's ports?
推荐答案
可能您正在尝试将docker容器端口22绑定到主机的已占用端口22.您需要将容器ssh服务器映射到主机的其他未占用端口,例如5000.
Probably you are trying to bind docker container port 22 to already occupied port 22 of your host. You need to map container ssh server to other not occupied port of your host e.g. 5000.
您可以在容器启动期间使用标志"-p HOST_PORT:CONTAINER_PORT"公开特定的端口:
You can expose particular ports during container start-up with flag "-p HOST_PORT:CONTAINER_PORT":
docker run -p 127.0.0.1:5000:22 docker_image
然后,您应该可以访问容器的GIT服务器:
Then you should be able to reach container's GIT server:
git add container container_user@127.0.0.1:5000/folder
git push container branch_name
这篇关于如何推送到容器上的git服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!