docker: archivo ejecutable no encontrado en PATH PATH


Tengo una imagen de docker que instala grunt, pero cuando intento ejecutarla, obtengo un error:

Error response from daemon: Cannot start container foo_1: \
    exec: "grunt serve": executable file not found in $PATH

Si corro bash en modo interactivo, grunt está disponible.

¿Qué estoy haciendo mal?

Aquí está mi Dockerfile:

# https://registry.hub.docker.com/u/dockerfile/nodejs/ (builds on ubuntu:14.04)
FROM dockerfile/nodejs

MAINTAINER My Name, [email protected]

ENV HOME /home/web
WORKDIR /home/web/site

RUN useradd web -d /home/web -s /bin/bash -m

RUN npm install -g grunt-cli
RUN npm install -g bower

RUN chown -R web:web /home/web
USER web

RUN git clone https://github.com/repo/site /home/web/site

RUN npm install
RUN bower install --config.interactive=false --allow-root

ENV NODE_ENV development

# Port 9000 for server
# Port 35729 for livereload
EXPOSE 9000 35729
CMD ["grunt"]
 127
Author: Steve Lorimer, 2014-11-27

6 answers

Cuando se utiliza el formato exec para un comando (por ejemplo, CMD ["grunt"], una matriz JSON con comillas dobles) se ejecutará sin un shell. Esto significa que la mayoría de las variables de entorno no estarán presentes.

Si especifica su comando como una cadena regular (por ejemplo, CMD grunt), entonces la cadena después de CMD se ejecutará con /bin/sh -c.

Más información sobre esto está disponible en la sección CMD de la referencia Dockerfile.

 120
Author: Kevan Ahlquist,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-26 06:54:46

Este fue el primer resultado en Google cuando pegué mi mensaje de error, y es porque mis argumentos estaban fuera de orden.

El nombre del contenedor tiene que ser después de todos los argumentos.

Malo:

docker run <container_name> -v $(pwd):/src -it

Bueno:

docker run -v $(pwd):/src -it <container_name>
 162
Author: sarink,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-23 18:26:31

Encontré el mismo problema. Hice lo siguiente:

docker run -ti devops -v /tmp:/tmp /bin/bash

Cuando lo cambio a

docker run -ti -v /tmp:/tmp devops /bin/bash

Funciona bien.

 18
Author: keniee van,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-18 13:07:24

Hay varias razones posibles para un error como este.

En mi caso, se debió a que el archivo ejecutable (docker-entrypoint.sh del Ghost blog Dockerfile) carecía del modo de archivo ejecutable después de haberlo descargado.

Solución: chmod +x docker-entrypoint.sh

 6
Author: Ben Creasy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-24 01:46:32

Hay varias razones posibles para un error como este. En mi caso, el contenedor o la imagen se bloquearán cuando mi computadora portátil se apague repentinamente. solución:

1 Retire el recipiente y la imagen

2 Reconstruir la imagen y Ejecutar el contenedor

Espero que ayude

 -1
Author: VithuBati,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-03 17:17:49

Para que funcione, agregue una referencia suave a/usr / bin:

Ln-s which (qué nodo) / usr / bin / node

Ln-s which (which npm) / usr / bin/npm

 -3
Author: vacavaca,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-11 13:11:41