krajwade
krajwade

Reputation: 133

Running simple script using docker-compose

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.

Upvotes: 1

Views: 653

Answers (1)

larsks
larsks

Reputation: 312630

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.

Upvotes: 2

Related Questions