1

I am new to docker. I am trying to run a very simple script as a service along with other service using docker-compose. I have created an image using Dockerfile with following details :

FROM bash 
CMD bash test_script.sh

I have redis and test_script images installed. My docker-compose.yml looks like this

version: '2'
services:

    redis:
       image: redis

    test-script:
       image: test-script  

My test_script looks like this

#!/bin/bash
echo "***************** Sleeping *****************"
sleep 10
echo "***************** Woke Up ******************"

When I run "docker-compose up", Redis starts properly but I get "bash: test_script.sh: No such file or directory". Any help is appreciated.

1 Answer 1

2

Docker is telling you the truth. You need to COPY your test_script.sh into the container. Something like:

FROM bash 
COPY test_script.sh /test_script.sh
CMD bash test_script.sh

This assumes that there is a file named test_script.sh in the same directory as your Dockerfile.

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

Comments

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.