6

I'm failing to build a docker image from a private bitbucket repository. My bitbucket repo has a "Dockerfile" on its root as described in the docker documentation.

docker --version

Docker version 1.3.1, build 4e9bbfa

I have tried...

docker build --rm=true --tag="myorg/myimagename" git://bitbucket.org:myacct/myrepo.git

error: fatal: unable to connect to bitbucket.org: bitbucket.org: Servname not supported for ai_socktype

docker build --rm=true --tag="myorg/myimagename" git://git@bitbucket.org:myacct/myrepo.git

error: fatal: unable to connect to bitbucket.org: bitbucket.org: Servname not supported for ai_socktype

Docs I'm following...

  • I am assuming my host machine's keys will be used.

When a Git repository is set as URL, then the repository is used as the context. The Git repository is cloned with its submodules (git clone -recursive). A fresh git clone occurs in a temporary directory on your local host, and then this is sent to the Docker daemon as the context. This way, your local user credentials and VPN's etc can be used to access private repositories.

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

  • I am also assuming docker will pickup the Dockerfile & context from the repository.

This will clone the GitHub repository and use the cloned repository as context. The Dockerfile at the root of the repository is used as Dockerfile. Note that you can specify an arbitrary Git repository by using the git:// schema.

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

I have already...

  • Setup my ssh keys correctly between bitbucket and my host machine
  • Successfully cloned the private bitbucket repo via ssh on the host machine
heme
  • 313
  • 2
  • 8
  • I don't believe you need to use the `git://` prefix for the repo if you're accessing it over ssh. see `http://stackoverflow.com/questions/23391839/clone-private-git-repo-with-dockerfile` – Anya Shenanigans Dec 09 '14 at 23:51
  • 1
    That question clones the repo inside of the Dockerfile and requires the correct keys inside of the docker image. Alternatively, I am sending my repo URL to the "build" command as a parameter. That said, I've tried without the `git://` but I get the error `no such file or directory`. – heme Dec 10 '14 at 12:33
  • 1
    It seems as thought the problem is that docker doesn't really support ssh cloning - https://github.com/docker/docker/issues/2715 - and it seems that 'magic' has been added in for github - https://github.com/docker/docker/pull/4364/files – Anya Shenanigans Dec 10 '14 at 15:32
  • 1
    Petesh's 2nd comment is the correct answer. – heme Mar 15 '16 at 20:41

1 Answers1

0

Replacing git:// with ssh:// will solve the problem.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Pejvan
  • 772
  • 5
  • 8
  • Petesh's 2nd comment above provides the correct answer. Relevant link - https://github.com/docker/docker/issues/2715 – heme Mar 15 '16 at 21:50