相关疑难解决方法(0)

在docker容器内使用SSH密钥

我有一个应用程序,使用Git执行各种有趣的东西(如运行git clone和git push),我正在尝试停靠它.

我遇到了一个问题,虽然我需要能够在容器中添加SSH密钥以供容器"用户"使用.

我尝试将其复制/root/.ssh/,更改$HOME,创建一个git ssh包装器,但仍然没有运气.

这是Dockerfile供参考:

#DOCKER-VERSION 0.3.4                                                           

from  ubuntu:12.04                                                              

RUN  apt-get update                                                             
RUN  apt-get install python-software-properties python g++ make git-core openssh-server -y
RUN  add-apt-repository ppa:chris-lea/node.js                                   
RUN  echo "deb http://archive.ubuntu.com/ubuntu precise universe" >> /etc/apt/sources.list
RUN  apt-get update                                                             
RUN  apt-get install nodejs -y                                                  

ADD . /src                                                                       
ADD ../../home/ubuntu/.ssh/id_rsa /root/.ssh/id_rsa                             
RUN   cd /src; npm install                                                      

EXPOSE  808:808                                                                 

CMD   [ "node", "/src/app.js"]
Run Code Online (Sandbox Code Playgroud)

app.js 像git一样运行git命令 git pull

ssh-keys docker

289
推荐指数
24
解决办法
23万
查看次数

用于克隆私有git仓库的Dockerfile

我正在尝试从github克隆私有git存储库.我做了一个像这样的Dockerfile:

FROM ubuntu:12.04

RUN apt-get update
RUN apt-get install -y git
RUN mkdir -p /root/.ssh/
ADD ./id_rsa /root/.ssh/id_rsa
RUN git clone git@github.com:usr/repo.git
Run Code Online (Sandbox Code Playgroud)

我在本地使用这个repo就好了,所以看起来我在Docker里面缺少一些东西.

我可能会遗漏的另一件事是,船坞~人和$HOME船坞人都指向/而不是/root,但我不确定这是否可以相关.

ssh docker

17
推荐指数
2
解决办法
2万
查看次数

与Heroku一起使用Git子模块

问题

我在Heroku上有一个Rails 3.1应用程序,很快就会需要一堆(第三方)子模块(其中一些子模块有子模块).不幸的是,Heroku缺乏子模块支持.Heroku网站上的一个建议是将子模块的内容移动到主仓库(这里).这将是第一次正常工作,但有可能它不会第二次.这可能是由于快速合并失败的第三方子模块之一的重大更新造成的.显然我们无法手动合并第三方项目.

解决方案"

我们的暂定解决方案如下:

  1. 根据最新的稳定dev分支创建一个新的"temp"分支,并将子模块合并到项目中.
  2. 结账到'heroku'分行.
  3. 核实此heroku分支的内容以避免任何可能的冲突,即创建一个删除所有内容的提交.
  4. 将temp分支合并到heroku分支中.
  5. 将此heroku分支推送到我们的heroku服务器.

优点

这将避免第三方子模块中的任何可能的冲突,并且是可编写脚本的.

Disavantages

这非常不优雅,是SVC的终极反模式.

问题

有一个更好的方法吗?

git heroku git-submodules

9
推荐指数
1
解决办法
7445
查看次数

在具有私有存储库依赖项的 docker 容器内使用 Bower

我正在尝试在 docker 容器内运行bower install,作为命令传递docker-compose.yml

相关代码在docker-compose.yml

services:
  assets:
    build: ./src
    command: >
      sh -c '
      bower install --allow-root;
      '
Run Code Online (Sandbox Code Playgroud)

具有bower.json以下依赖性:

{
  "name": "projectname",
  "version": "version",
  "dependencies": {
    "remote-repo": "ssh://git@remoterepo.url/repo.git#branch"
  }
}
Run Code Online (Sandbox Code Playgroud)

这个远程仓库是私有的。主机具有可以从该远程提取的正确 SSH 凭据。

我尝试过 4 或 5 种不同的方式将 SSH 凭据从我的主机传递到 docker 容器,但每次尝试都会出现相同的错误消息:

docker_1   | bower repo#branch          ECMDERR Failed to execute "git 
ls-remote --tags --heads ssh://git@remoterepo.url/repo.git", exit code 
of #128 Host key verification failed. fatal: Could not read from 
remote repository.  Please make sure …
Run Code Online (Sandbox Code Playgroud)

git ssh bower docker

7
推荐指数
1
解决办法
1039
查看次数

在docker文件中将私钥添加到ssh-agent

我正在尝试为angular cli项目编写一个docker文件,但我有一个外部依赖项,它是BitBucket上的私有仓库,所以我需要传递我的ssh密钥.我正在尝试使用ssh密钥--build-arg

现在的问题是,它没有将这些密钥添加到ssh-agent并要求输入密码.

我正在使用此命令运行 docker build -t ng-2-docker/client --build-arg ssh_prv_key="$(cat ~/.ssh/id_rsa)" --build-arg ssh_pub_key="$(cat ~/.ssh/id_rsa)" .

这是我的docker文件

ARG ssh_prv_key
ARG ssh_pub_key

# Use an official Node runtime as a parent image
FROM node:8.9.4

# Specify working directory in docker container
WORKDIR /app

# Authorize SSH Host
RUN mkdir -p /ssh/
RUN chmod 0700 /ssh

# Add the keys and set permissions
RUN echo "$ssh_prv_key" > /ssh/id_rsa && echo "$ssh_pub_key" > /ssh/id_rsa.pub && chmod 600 /ssh/id_rsa && chmod 600 /ssh/id_rsa.pub

# …
Run Code Online (Sandbox Code Playgroud)

git ssh docker dockerfile

7
推荐指数
3
解决办法
5033
查看次数

heroku + git子模块需要身份验证

我们使用gitolite来管理我们的存储库,我们的一个heroku项目有git子模块.有没有办法获得Heroku的身份验证公钥?

谢谢,大卫

git heroku gitolite

6
推荐指数
1
解决办法
3358
查看次数

从私有 git 存储库构建 Docker 映像

我无法从私有 bitbucket 存储库构建 docker 映像。如 docker 文档中所述,我的 bitbucket 存储库在其根目录上有一个“Dockerfile”。

码头工人--版本

Docker version 1.3.1, build 4e9bbfa
Run Code Online (Sandbox Code Playgroud)

我试过了...

docker build --rm=true --tag="myorg/myimagename" git://bitbucket.org:myacct/myrepo.git
Run Code Online (Sandbox Code Playgroud)

错误:致命:无法连接到 bitbucket.org:bitbucket.org:ai_socktype 不支持 Servname

docker build --rm=true --tag="myorg/myimagename" git://git@bitbucket.org:myacct/myrepo.git
Run Code Online (Sandbox Code Playgroud)

错误:致命:无法连接到 bitbucket.org:bitbucket.org:ai_socktype 不支持 Servname

我正在关注的文档...

  • 我假设将使用我主机的密钥。

当 Git 存储库设置为 URL 时,存储库将用作上下文。Git 存储库与其子模块 (git clone -recursive) 一起克隆。新的 git clone 出现在本地主机上的临时目录中,然后将其作为上下文发送到 Docker 守护程序。这样,您的本地用户凭据和 VPN 等可用于访问私有存储库。

https://docs.docker.com/reference/commandline/cli/#build

  • 我还假设 docker 将从存储库中获取 Dockerfile 和上下文。

这将克隆 GitHub 存储库并将克隆的存储库用作上下文。存储库根目录下的 Dockerfile 用作 Dockerfile。请注意,您可以使用 git:// 架构指定任意 Git 存储库。

https://docs.docker.com/reference/commandline/cli/#examples_1

我已经...

  • 在 bitbucket 和我的主机之间正确设置我的 ssh 密钥
  • 在主机上通过 ssh …

bitbucket docker dockerfile

6
推荐指数
1
解决办法
5564
查看次数

如何从Docker容器克隆Git存储库

我们有一个工具,需要克隆几个Git存储库以汇总文档数据。我们希望将该工具放在Docker容器中,以便在本地和Jenkins轻松运行它,并实现可重复性。

Git存储库托管在需要使用SSH密钥进行身份验证的专用服务器上。因此,Docker容器必须以某种方式获得对运行该容器的用户的SSH密钥的访问权限。

我们有一个约束列表:

  1. 我们希望将泊坞窗图像中嵌入的SSH密钥
  2. 我们希望用户构建Docker映像。我们认为Dockerfile不会启用可重现性,而已经生成的Docker映像可以
  3. 我们希望容器以root用户身份运行
  4. 我们使用运行容器的主机用户的SSH密钥
  5. 参数可被提供给该命令启动容器(-v-u,...)

问题:如果可能的话,我们如何实现?

有关:

git ssh-keys docker

6
推荐指数
2
解决办法
2348
查看次数

尝试将存储库克隆到 Windows 7,其中包含“aux”目录

在尝试克隆 git repo -特别是jpeginfo 时- 发生错误,

Cloning into 'jpeginfo'...
remote: Counting objects: 182, done.
remote: Total 182 (delta 0), reused 0 (delta 0), pack-reused 182R
Receiving objects: 100% (182/182), 115.71 KiB | 140.00 KiB/s, done.
Resolving deltas: 100% (99/99), done.
Checking connectivity... done.
fatal: cannot create directory at 'aux': Invalid argument
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
Run Code Online (Sandbox Code Playgroud)

显然,目录的“aux”名称是 Windows …

git windows-7

5
推荐指数
1
解决办法
1502
查看次数

我可以在 docker-compose 中使用 Windows 10 主机的 git 凭据吗?

我想将 Windows 10 主机的 git 凭据与 docker-compose 一起使用,而无需在容器中输入凭据。

编辑

不应该将我的密钥保存在图像中。开发人员都将运行基于同一镜像的容器。理想情况下,当容器启动时,通过 docker-compose,它将使用各个开发人员的 git 凭据从 git 存储库中提取内容。

镜像是 Ubuntu,而主机是 Windows 10,使用 Git Credential Manager for Windows (GCM) 作为凭证​​助手。

git docker docker-compose

5
推荐指数
1
解决办法
1552
查看次数

aws docker 中没有 EXPOSE 部署失败

我有一个由托管在 docker 镜像内的 cron 持续运行的 scrapy 项目。

当我在本地运行并部署它时,一切正常。如果我尝试将其部署到 AWS,我会在日志中收到以下错误:

No EXPOSE directive found in Dockerfile, abort deployment (ElasticBeanstalk::ExternalInvocationError)
Run Code Online (Sandbox Code Playgroud)

控制台显示我的容器已正确构建,但如果没有 EXPOSED 端口,我无法使用它。

INFO: Successfully pulled python:2.7
WARN: Failed to build Docker image aws_beanstalk/staging-app, retrying...
INFO: Successfully built aws_beanstalk/staging-app
ERROR: No EXPOSE directive found in Dockerfile, abort deployment
ERROR: [Instance: i-6eebaeaf] Command failed on instance. Return code: 1 Output: No EXPOSE directive found in Dockerfile, abort deployment.
Hook /opt/elasticbeanstalk/hooks/appdeploy/enact/00run.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command …
Run Code Online (Sandbox Code Playgroud)

python amazon-web-services amazon-elastic-beanstalk dockerfile

2
推荐指数
1
解决办法
3343
查看次数