How can I make docker-compose build an image from a remote git repository?
Solution 1:
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
Solution 2:
The file tests/unit/config/config_test.py
shows:
def test_valid_url_in_build_path(self):
valid_urls = [
'git://github.com/docker/docker',
'[email protected]:docker/docker.git',
'[email protected]:atlassianlabs/atlassian-docker.git',
'https://github.com/docker/docker.git',
'http://github.com/docker/docker.git',
'github.com/docker/docker.git',
]
This is confirmed with compose/config/config.py#L79-L85
:
DOCKER_VALID_URL_PREFIXES = (
'http://',
'https://',
'git://',
'github.com/',
'git@',
)
Solution 3:
I think there is a better way to do this now!
If you want to use a Dockerfile that's located inside the repo and the repo is public, your best guess is to use the raw file.
E.g. for the file Dockerfile_dev inside https://github.com/certbot/certbot, you could use https://raw.githubusercontent.com/certbot/certbot/master/Dockerfile-dev
Then in docker-compose, add it like this in order to use the Dockerfile from the remote location.
certbot_dev:
image: certbot-dev
build: https://raw.githubusercontent.com/certbot/certbot/master/Dockerfile-dev
You can find the raw link, when you click on a button called 'Raw' inside the file preview: https://github.com/certbot/certbot/blob/master/Dockerfile-dev