Reputation: 68
I tried with #!/usr/bin/bash
and #!/usr/bin/env/sh
and #!/usr/bin/env/ bash
docker run -t -i image-id /bin/sh
is what i use and use ls
and i see that the file is there
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c970708c1a3 bd24c6bef682 "/bin/sh -c 'sh benc…" 7 minutes ago Exited (127) 7 minutes ago amazing_lovelace
I am able to run both these commands individually and they work
echo "Getting the Container Name"
containerName=$(docker ps -l --format '{{.Names}}' 2>&1)
echo "Transfering the text file"
docker cp $containerName:/benchmark.txt /Users/xxxx/Devlocal/xxxxx/tests/logs/benchmark.txt
when put in a shell script and run i get: ERROR
benchmark.sh: line 13: docker: not found
The command '/bin/sh -c sh benchmark.sh' returned a non-zero code: 127
please help dockerfile
FROM gliderlabs/alpine:3.5
MAINTAINER LN
RUN apk add --update alpine-sdk openssl-dev
RUN apk add --no-cache git
RUN git clone https://github.com/giltene/wrk2.git && cd wrk2 && make
ADD ["benchmark.sh", "/benchmark.sh"]
RUN sh benchmark.sh
Upvotes: 0
Views: 375
Reputation: 1970
The script that you call inside the container, executes docker commands. This can only work if you have docker installed in your container, which, by the looks of it, it is not.
If your only aim is to have access to the file /benchmarks.txt
, you can mount it when you start your container:
docker run -d -v /Users/xxxx/Devlocal/xxxxx/tests/logs/benchmark.txt:/benchmark.txt ...
Note that you have to add RUN touch /benchmark.txt
to your Dockerfile.
The reason for that is here
Upvotes: 1