Mornor
Mornor

Reputation: 3801

docker-compose not found from script

I have a Dockerfile which is basically the following:

FROM mhart/alpine-node:5

COPY . /project
WORKDIR /project

ENTRYPOINT ["./startup.sh"]

And my startup.sh is quite simple too:

#!/bin/sh
set -e
docker-compose up -d

I do have a docker-compose.yml, but there is no point to describe it here.

First thing I do is to build the docker image by using my Dockerfile, so:

docker build -t test .

Then run this image:

docker run -d test

Which will launch the startup.sh

Unfortunately, I have the following error showing up:

./startup.sh: line 10: docker-compose: not found

And if I do only ./startup.sh without the docker stuff, it works like a charm.

Where the issue can be possibly coming from?

Upvotes: 2

Views: 3344

Answers (1)

cb0
cb0

Reputation: 8643

Try to add the full path to the docker-compose inside the script

which docker-compose

>/usr/bin/some/path/docker-compose

Then add this to your script

#!/bin/sh
set -e
/usr/bin/some/path/docker-compose up -d

Your local PATH settings are unknown to the script called by docker. Therefore you have to name the full path.

Upvotes: 2

Related Questions