0

Im building a docker-compose service that probes for my db service to start before starting a test on my app. The docker-compose files worked great and I just created a new host with a docker machine and now I get an error when running:

docker-compose up agent

this is my docker-compose.yml

test:
  build: ../../
  dockerfile: docker/dev/Dockerfile
  volumes_from:
    - cache
  links:
    - db
  environment:
    DJANGO_SETTINGS_MODULE: todobackend.settings.test
    MYSQL_HOST: db
    MYSQL_USER: root
    MYSQL_PASSWORD: password
    TEST_OUTPUT_DIR: /reports

builder:
  build: ../../
  dockerfile: docker/dev/Dockerfile
  volumes:
    - ../../target:/wheelhouse
  volumes_from:
    - cache
  entrypoint: "entrypoint.sh"
  command: ["pip", "wheel", "--no-index", "-f /build", "."] 

agent:
  image: pjestrada/ansible
  volumes:
    - ../../ansible/probe.yml:/ansible/site.yml
  links:
    - db
  environment:
    PROBE_HOST: "db"
    PROBE_PORT: "3306"

db:
  image: mysql:5.6
  hostname: db
  expose:
    - "3306"
  environment:
    MYSQL_ROOT_PASSWORD: password

cache:
    build: ../../
    dockerfile: docker/dev/Dockerfile
    volumes:
      - /tmp/cache:/cache
      - /build
    entrypoint: "true"

my playbook:

---
- name: Probe Host
  hosts: localhost
  connection: local
  gather_facts: no
  tasks:
  - name: Set facts
    set_fact:
      probe_host: "{{ lookup('env', 'PROBE_HOST') }}"
      probe_port: "{{ lookup('env', 'PROBE_PORT') }}"
      probe_delay: "{{ lookup('env', 'PROBE_DELAY') | default(0, true) }}"
      probe_timeout: "{{ lookup('env', 'PROBE_TIMEOUT') | default (180, true) }}"
  - name: Message
    debug:
      msg: >
        Probing {{ probe_host }}:{{ probe_port }} with delay={{ probe_delay }}s
        and timeout={{ probe_timeout }}s 
  - name: Waiting for hosts to respond...
    local_action: >
      wait_for host={{ probe_host }}
      port={{ probe_port }}
      delay={{ probe_delay }}
      timeout={{ probe_timeout }}

and my ansible Dockerfile:

FROM ubuntu:trusty
MAINTAINER Pablo Estrada <pjestradac@gmail.com>

# Prevent dpkg errors
ENV TERM=x-term-256color


RUN sed -i "s/http:\/\/archive./http:\/\/nz.archive./g" /etc/apt/sources.list


#Install ansible

RUN apt-get update -qy && \
    apt-get install -qy software-properties-common && \
    apt-add-repository -y ppa:ansible/ansible && \
    apt-get update -qy && \
    apt-get install -qy ansible

# Add voulme for Ansible Playbooks
Volume /ansible
WORKDIR /ansible




#Entrypoint
ENTRYPOINT ["ansible-playbook"]
CMD ["site.yml"]

The error I get says: ERROR! the playbook: site.yml does not appear to be a file

I dont understand why this happens if Im mapping the probe.yml to site.yml on my docker compose file. Is there anything wrong with my images?? Thanks for the help.

UPDATE

Aparently the issue happens when I start my docker machine and use

eval $(docker-machine env)

this is my docker machine info:

default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.1  

When everything worked I did not have any docker host up with docker-machine. What can be happening here?

Pablo Estrada
  • 3,182
  • 4
  • 30
  • 74

1 Answers1

1

It's likely you've specified a path to a probe.yml that doesn't exist on the VM, and docker (being helpful) created a directory and mounted that for you.

○ →ls -l
total 8
-rw-r--r--  1 user  staff  110 13 Sep 05:26 docker-compose.yml

○ →docker-compose run agent ansible-playbook site.yml
ERROR! the playbook: site.yml does not appear to be a file

○ →ls -l
total 8
-rw-r--r--  1 user  staff  110 13 Sep 05:26 docker-compose.yml
drwxr-xr-x  2 user  staff   68 13 Sep 05:31 site.yml

The directory you are using locally might not be shared to the VM? Although you should have a lot more than just the agent failing if that were the case.

Sharing from linux to a local VM

To quote the git repo

In case it isn't already clear, the Linux host support here is currently hazy.

It sounds like sharing /home as a shared folder called /Users will allow your home directories to be automounted in the local Docker VM. If you create a link to /home called /Users and run your docker commands from there that will make the directory paths look the same in both the VM and local machine, and Docker should be happy.

ln -s /home /Users
VBoxManage sharefolder add "default" --name "/Users" --hostpath "/Users"
cd /Users/you/project
eval $(docker-machine env default)
docker-compose run whatever
Matt
  • 68,711
  • 7
  • 155
  • 158
  • Its very likely that i dont have share the folders. How do I specify the folders to share to my docker-machine? – Pablo Estrada Sep 13 '16 at 05:42
  • Docker Toolbox (boot2docker) will share the `/Users` or `C:/Users` directories by default into the vm as `/Users` or `/c/Users`. Other than that you have to set it up manually: http://stackoverflow.com/a/33245360 – Matt Sep 13 '16 at 05:50
  • and from memory it's hard to persist custom shares in boot2docker – Matt Sep 13 '16 at 05:50
  • Whats the best way to go about it on Linux? Im using ubuntu – Pablo Estrada Sep 13 '16 at 05:51