I have a Dockerfile which works if i make a container out of it, but doesnt work completely when i run it via compose yaml file.
so below is the Dockerfile, and i copy a shell.sh from my localmachine to container, all ok in this case.
Dockerfile:
FROM alpine:latest
LABEL maintainer="[email protected]"
RUN mkdir -p /tmp/hasham
COPY ./shell.sh /tmp/hasham/
RUN chmod 775 /tmp/hasham/shell.sh
RUN echo '*/1 * * * * /tmp/hasham/shell.sh' > /etc/crontabs/root
CMD crond && sleep infinite
The shell script gets copied from my context directory into the container at /tmp/hasham/
However the problem is whenever I run this dockerfile as a part of docker compose, the shell script created on the container is empty. the filename is there in the container but with no contents. I dont understand why is this happening only when running through compose. I tried with another simple text file also and got the same problem, file is created but is with zero size and no contents.
please can someone tell me what am i doing wrong?
below is the yaml file im using and it is referencing the above Dockerfile for container generation.
test.yaml
services:
my_app:
container_name: myapp
build:
dockerfile: ./alpine.Dockerfile
networks:
- mynetwork
networks:
mynetwork:
name: mynetwork
driver: bridge
please help !
thanks
H
dont think its anything to do with permissions?
docker build works fine (create image and then container)
docker compose doesnt work fine, i get empty /tmp/hasham/shell.sh (composing using the above dockerfile)
docker compose --project-name my_project -f test.yaml up -d
Hasham1983 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1