ensure network is created before building image

This commit is contained in:
Michael Becker 2025-01-12 22:11:27 -05:00
parent b48794992a
commit b2b1c386eb

View File

@ -8,10 +8,18 @@ SUV_NAME=i-0$SUV_ID
# build the image (i.e. 'mocha suv init' ) # build the image (i.e. 'mocha suv init' )
docker build -t mocha-httpd -f mocha-suv/docker/Dockerfile . docker build -t mocha-httpd -f mocha-suv/docker/Dockerfile .
docker network create --driver=bridge --subnet=10.7.0.0/16 --ip-range=10.7.0.0/24 --gateway=10.7.0.1 mocha-docker
# initiate a container (i.e. 'mocha suv up i-0...' ) # initiate a container (i.e. 'mocha suv up i-0...' )
docker run --name $SUV_NAME -d --net mocha-docker -it mocha-httpd # -p 8000:80 mocha-httpd docker run --name $SUV_NAME -d --net mocha-docker -it mocha-httpd # -p 8000:80 mocha-httpd
echo "waiting for network to settle..." echo "waiting for network to settle..."
sleep 3 sleep 3
docker inspect $SUV_NAME # docker inspect $SUV_NAME
SUV_IP=$(docker container exec $SUV_NAME hostname -i)
echo "Enter administrative password to add entry to /etc/hosts file if wanted"
echo -e "$SUV_IP\t\t$SUV_NAME.privatesuv.com" | sudo tee -a /etc/hosts
# echo "$SUV_NAME : $SUV_IP"