You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ASYD/ASYD_Docker/docker-03/chello-world/build.sh

23 lines
751 B

#!/bin/bash
# get the image name from the current working directory
IMG_NAME=$(basename $(pwd))
# create a random container name and use throuout this scrip
CNTR=$(date | md5sum | head -c 10)
docker build -t $IMG_NAME .
echo "starting the container with: 'docker run --rm $IMG_NAME'"
echo "creating a container with: 'docker create --name $CTNR $IMG_NAME'"
docker create --name $CNTR $IMG_NAME
echo "copying /myapp from container to host: 'docker cp $CNTR:/myapp/hello-world .'"
docker cp $CNTR:/myapp/hello-world .
echo "removing the container with: 'docker rm $CTNR'"
docker rm $CNTR
echo "starting hello-world from the host: './hello-world'"
./hello-world
# echo "to start a bash in the container, run: 'docker run --rm -it $IMG_NAME bash'"