Docker Community Forums

Share and learn in the Docker community.

Entrypoint problem, standard_init_linux.go:190:


#1

dockerfile

FROM php:5-apache

COPY ./docker-entrypoint.sh /

RUN ["chmod", "+x", "/docker-entrypoint.sh"]

ENTRYPOINT ["/docker-entrypoint.sh"]

docker-entrypoint.sh

#!/bin/bash
echo "Hello World"

docker-compose.yml

version: ‘3’

services:
postgres:
build: ./post
restart: always

start by
docker-compose up

and have

postgres_1 | standard_init_linux.go:190: exec user process caused “no such file or directory”

What is wrong???


(Ove "Lime" Lindström) #2

Hi,

Maybe the PHP-image is not the best one to play around with this. :smiley:

Looking at the PHP Dockerfile (https://github.com/docker-library/php/blob/783878384a8f3953ed571e5a34ba0fe546726c85/5.6/stretch/apache/Dockerfile) you can see that they are using ENTRYPOINT ["docker-php-entrypoint"].

I usually put my entripoint scripts (depending on base image) in the directory /usr/local/bin/

Have a look at https://medium.freecodecamp.org/docker-entrypoint-cmd-dockerfile-best-practices-abc591c30e21

Edit:
I did a test with all your files in the same directory and that works like a charm. The only thing I did change was that my docker-compose.yml looks like this and does not build form the ./post directory.

version: '3'

services:
  php:
    build: .
    restart: always

#3

now i make

version: ‘3’

services:
php:
build: ./web
restart: always

docker-entrypoint.sh

#!/bin/sh
set -e
if [ “${1#-}” != “1" ]; then set -- apache2-foreground "@”
fi

exec “$@”

Dockerfile

FROM php:5-apache

COPY ./docker-entrypoint.sh /usr/local/bin/

RUN [“chmod”, “+x”, “/usr/local/bin/docker-entrypoint.sh”]

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

dont work

docker@debian:~/test$ docker-compose up
WARNING: Found orphan containers (test_postgres_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Recreating test_php_1 … done
Attaching to test_php_1
test_php_1 exited with code 0

why???


(Ove "Lime" Lindström) #4

In your first docker-compose, you named the service postgres and started the services. Then you changed the service name to php and tried to do a docker-compose up again. That leaves the service and container state of the previous one in an orphaned state, as it states in the error message.

To fix this, run the command docker-compose down --rmi all --remove-orphans

I have been thought to either do docker-compose build && docker-compose upor docker-compose --build up.

When running in a development environment, I like to use the --force-recreate flag also.


#5

Its work for me, but how to start apache from docker-entrypoint.sh ?