Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make docker-compose build an image from a remote git repository?

Docker-compose allows you to utilize either preëxisting docker images or build from source. For the build option, the official reference requires

Either a path to a directory containing a Dockerfile, or a url to a git repository.

I'd like to take advantage of the latter case, so that I don't have to create a git submodule in my project, or register a new repository on Docker Hub. Unfortunately, there are no examples for how to format the url, and every form I've tried is mistaken for a relative file path.

e.g.

--- letsencrypt:   build: https://github.com/letsencrypt/letsencrypt.git ... 

Fails with the error:

ERROR: build path /{MY_CURRENT_PATH}/https:/github.com/letsencrypt/letsencrypt.git either does not exist or is not accessible.

I didn't have any more luck with the other forms I've tried:

  • [email protected]:letsencrypt/letsencrypt.git
  • git://github.com/letsencrypt/letsencrypt.git
  • https://github.com/letsencrypt/letsencrypt
like image 985
billkw Avatar asked Dec 06 '15 17:12

billkw


People also ask

Can you build images using Docker compose?

From your project directory, start up your application by running docker compose up . Compose pulls a Redis image, builds an image for your code, and starts the services you defined. In this case, the code is statically copied into the image at build time.


1 Answers

Are you running version 1.5.2? It looks like this was actually recently added in https://github.com/docker/compose/pull/2430. Try upgrading.

Example:

---  version: '2'  services:   redis:     image: "redis:3.2.3"     hostname: redis    redis-commander:     build: https://github.com/joeferner/redis-commander.git     command: --redis-host redis     links:       - "redis:redis"     ports:       - 8081 

Tested with:

$ docker-compose -v docker-compose version 1.11.2, build dfed245 
like image 183
Andy Shinn Avatar answered Sep 21 '22 18:09

Andy Shinn