Reputation: 1717
I would like to automate the build process of my application through the following steps:
build-system
container that has all dependencies and scripts for making the final exe of my application.docker cp
or by attaching a volume while launching the container.dist-system
container, which is essentially the final image that will be stored in Docker hub.docker commit
of the dist-system container and then docker push
the image to Docker hub from the host machine.My question relates specifically to points 3 and 6 where I need to know that the bash scripts have completed execution within the containers. Only then I would like to fire docker commands in the host machine. Is there a way in which docker can be notified of bash script execution within containers?
Upvotes: 0
Views: 2634
Reputation: 36
docker run
is synchronous, and by default will block until the docker container exits.
For example, if the build-system
Dockerfile looks like this:
FROM alpine:latest
COPY ./build.sh /build.sh
VOLUME /data
CMD ["/build.sh", "/data/test.out"]
With build.sh
as follows:
#!/bin/sh
sleep 5
echo "Hello world!" >> "$1"
exit 0 # docker run will exit with this code, you can use this to check if your build was successful
Running docker run --rm -v /your/work/directory/build-output:/data build-system
will wait 5 seconds and then exit, and /your/work/directory/build-output/test.out
will have been created.
Upvotes: 2