jayfk / docker-recipes

Recipes from docker-recipes.com
https://docker-recipes.com
2 stars 3 forks source link

Container command '/bin/bash' not found or does not exist. #1

Open erikaulin opened 8 years ago

erikaulin commented 8 years ago

Hi, tried to use the example but fails so start.

➜ auto-haproxy git:(master) docker-compose up -d autohaproxy_app_1 is up-to-date Starting autohaproxy_haproxy-gen_1

ERROR: for haproxy-gen Container command '/bin/bash' not found or does not exist. Traceback (most recent call last): File "", line 3, in File "compose/cli/main.py", line 63, in main AttributeError: 'ProjectError' object has no attribute 'msg' docker-compose returned -1

Think docker has change how volumes are created and the naming now uses catalog name.

➜ auto-haproxy git:(master) docker volume ls | grep haproxy local autohaproxy_haproxy_cfg

➜ auto-haproxy git:(master) docker-compose -v docker-compose version 1.7.1, build 0a9ab35

➜ auto-haproxy git:(master) docker -v Docker version 1.11.2, build b9f10c9

joshhsoj1902 commented 8 years ago

I didn't trace back what caused this to start happening, but I was able to work around it by installing bash as part of the dockergen Dockerfile:

RUN apk add bash bash-doc bash-completion

So this is what my dockerfile looks like now:

FROM jwilder/docker-gen COPY haproxy.tmpl /etc/docker-gen/templates/haproxy.tmpl COPY run.sh /run.sh RUN chmod +x /run.sh RUN apk add bash bash-doc bash-completion ENTRYPOINT ["/bin/bash", "-c"] CMD ["/run.sh"]

dotLou commented 8 years ago

The even better thing to do would be to remove the need for run.sh outright and move that command to your Dockerfile directly, as so: CMD ["sh", "-c", "/usr/local/bin/docker-gen -notify-sighup ${PROJECT}_${SERVICE}_1 -watch /etc/docker-gen/templates/haproxy.tmpl /usr/local/etc/haproxy/haproxy.cfg"]

So the full file now looks like this:

FROM jwilder/docker-gen
COPY haproxy.tmpl /etc/docker-gen/templates/haproxy.tmpl
CMD ["sh", "-c", "/usr/local/bin/docker-gen -notify-sighup ${PROJECT}_${SERVICE}_1 -watch /etc/docker-gen/templates/haproxy.tmpl /usr/local/etc/haproxy/haproxy.cfg"]
jayfk commented 8 years ago

@dotLou Is this working? I had this in mind initially, but ended with obscure errors.

dotLou commented 8 years ago

I think it's an issue if you don't specify "sh", "-c" but otherwise seems to work for me.

dotLou commented 8 years ago

I think I take that back.. I need to further investigate, it's not working anymore :(