Below are the steps in creating the docker.sh shell script:
-
Begin the line with the shebang
#!/bin/bash
to specify that the bourne again shell is required to run this script. -
The LF unix-style line ending is essential to avoid vague errors.
-
Use
docker pull
to make initial downloads of the required images. -
Copy the provided static site html file from current working directory to user directory.
-
Run
docker run
to create the containers. We use the-dit
flag to run them in detached mode with an interactive prompt on/bin/bash
. Make sure to name the containers for further reference. In the Nginx case, map the local8080
port to the container's80
port. Copy the site contents from~/site-packages
into a mounted volume. -
We will need to use ping, which is available by default on the Kibana image. Install on the other containers by running
docker exec
with the appropriate install directives. -
Create a bash array to reference the container names for repetitive commands.
-
Create a docker bridge network
entNet
. -
Connect each container to this new network.
-
Inspect the network to confirm.
-
Run
docker exec
into each instance and ping the two other instances with two pulses each. -
Run
docker exec
into the Kibana container andcurl
the Nginx container to verify web functionality. -
Create the cleanup script to tidy things up.
-
Annotate with comments and echos for clarity.