elastic / crawler

Other
109 stars 8 forks source link

document volume mounting and docker-compose options #153

Open seanstory opened 1 week ago

seanstory commented 1 week ago

Problem Description

There are a lot of ways to start a docker container that needs a local file. Currently, we document doing it with docker run and docker cp like:

$ docker run -i -d \
  --network elastic \
  --name crawler \
  docker.elastic.co/integrations/crawler:0.2.0
$ docker cp config/my-crawler.yml crawler:app/config/my-crawler.yml
$ docker exec -it crawler bin/crawler crawl path/to/my-crawler.yml

But small changes to any of these commands might lead to unexpected results, especially if you don't fully appreciate what you changed.

To add some more safety net, we can document alternative methods too, so that if one doesn't work for a user, they don't have to go digging through docker docs to figure out how to do it differently.

Proposed Solution

Provide an example docker-compose.yml like:

services:
  elastic-open-web-crawler:
    image: docker.elastic.co/integrations/crawler:0.2.0
    stdin_open: true
    volumes:
    - ${PWD}/crawler-config.yml:/app/config/crawler-config.yml:ro

which could be started with:

$ docker compose exec elastic-open-web-crawler bin/crawler crawl /app/config/crawler-config.yml
ugosan commented 1 week ago

I believe mounting volumes on containers is preferable over copying files, at least the former is a much more common practice than the latter.