I am working in a Dockerfile for PHP-FPM 7.1. I am ending the Dockerfile with the following line:
CMD ["php71-php-fpm"]
Because I am using docker-compose
this is how I start up the container:
docker-compose up -d
The container compiles fine (apparently) as per this lines:
Successfully built 014e24455b53
WARNING: Image for service php was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating php71-fpm
But it ends with the following error:
ERROR: for php Cannot start service php: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"php71-php-fpm\\\": executable file not found in $PATH\"\n"
ERROR: Encountered errors while bringing up the project.
I have tried the following:
CMD php71-php-fpm
And the error disappear but then the container exit with code 127:
> docker-compose ps
Name Command State Ports
-------------------------------------------------------
php71-fpm /bin/sh -c php71-php-fpm Exit 127
What I am missing here?
UPDATE
I have found the following answer here:
Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.
Which makes me think that the file php71-paths.sh is not being executed so the paths are not setup properly.
Once again, what I am missing?
This php71-fpm
will be linked with another container running Nginx (this is a WIP and my way to learn Docker)
Here it's the complete Dockerfile for you to take a look.
I believe you're running into trouble because the default shell run by Docker is not a login shell according to this answer, which means scripts in /etc/profile.d/
don't get processed.
If you need profile processing, try changing your last line to CMD ["/bin/sh", "-l", "-c", "php71-php-fpm"]
to invoke a login shell.