0

I've a working dockerfile to setup elasticsearch as follows :

FROM elasticsearch:6.5.4
WORKDIR /app
ADD . /app
ADD analysis /usr/share/elasticsearch/config/analysis
COPY test.sh .
EXPOSE 9200
EXPOSE 9300

my current file directory is as follows :

C:.
|   Dockerfile
|   test.sh
|
+---analysis
|       wn_s.pl
|
\---poppler
    +---bin
    |       AUTHORS
    |       BINARIES
    |       COPYING
    |       COPYING3
    |       freetype6.dll
    |       jpeg62.dll

I want to give the bin folder inside poppler as environment variable PATH for elasticsearch. To do this, i appended my dockerfile with

FROM elasticsearch:6.5.4
WORKDIR /app
ADD . /app
ADD analysis /usr/share/elasticsearch/config/analysis
COPY test.sh .
EXPOSE 9200
EXPOSE 9300
ENV PATH=/app/es/poppler/bin

As a result, image is created but when a container is made using that image, its exits on start with following error in docker logs :

/usr/local/bin/docker-entrypoint.sh: line 62: env: command not found
/usr/local/bin/docker-entrypoint.sh: line 93: id: command not found
/usr/local/bin/docker-entrypoint.sh: line 8: id: command not found
/usr/share/elasticsearch/bin/elasticsearch: line 17: dirname: command not found
/usr/share/elasticsearch/bin/elasticsearch: line 17: /elasticsearch-env: No such file or directory
/usr/share/elasticsearch/bin/elasticsearch: line 20: : command not found
/usr/share/elasticsearch/bin/elasticsearch: line 25: grep: command not found
/usr/share/elasticsearch/bin/elasticsearch: line 27: exec: : not found

I've had success with adding environment variables in the similar way in previous projects, however, despite searching over stackoverflow, i've not been able to figure out the point where it is going wrong.

2
  • grep: command not found grep is also from an environment variable? Commented Aug 9, 2019 at 11:44
  • 2
    It's because you replaced the PATH environment variable with your value instead of adding it to the PATH variable. Commented Aug 9, 2019 at 11:44

2 Answers 2

1

You just overwrote default PATH so container cannot find any of the executables that's why you see those errors.

Fix: ENV PATH="/app/es/poppler/bin:${PATH}"

That will allow you to keep exisitng PATH and add your customization.

Sign up to request clarification or add additional context in comments.

1 Comment

this works great in dockerfile, but when using the same dockerfile with docker-compose, it throws an error stating Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown
1

As suggested in the comment, you replaced the value of PATH environment variable instead of adding your value to it.

Replace,

ENV PATH=/app/es/poppler/bin

with

ENV PATH='${PATH}:/app/es/poppler/bin'

2 Comments

the solution provided by @jakub Bujny worked, does that mean the version you said is wrong. if not, can you please explain the difference between the two. Thanks
@IrfanHarun: Both the solutions suggested are essentially the same with a minor difference. I put the default value of PATH first and appended /app/es/poppler/bin later. Let's say a utility named grep exists in the default PATH variable and there is also an executable binary named 'grep' in the newly added path '/app/es/poppler/bin. With such a case, for my answer, the system's grep` will be executed and for Jakub's answer, the grep in the newly added path will be executed, when grep command is fired without mentioning the absolute path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.