Automatic Docker Container Creation Via Linux Bash Script

Automatic Docker Container Creation Via Linux Bash Script

Here is another useful script for Docker beginners. Automatic Docker Container Creation via Linux Bash Script.

This script will create two Docker containers ‘WordPress’ and ‘MYSQL’. Read more for information about Docker.

Prerequisites package needed for Automatic Docker Container Creation via Linux Bash Script to work flawlessly. Docker host should have ‘dialog’ package installed.

For Ubuntu:
# apt-get install -y dialog

For CentOS:
# yum install dialog

Download the script for Automated Docker Container Creation from https://gitlab.com/am.senthilnathan/docker/-/blob/main/docker-build.sh and follow the below procedures or go through the README file in GitLab.

  • Make the script executable by running the below command,
    # chmod +x docker-build.sh
  • Run the script, # sh docker-build.sh
  • Once the script execution is completed, run the command # docker ps to view the running containers as shown in below figure,
  • Use the docker host IP address in the browser to set up the WordPress website by using the below details:

Database Host: mysql
Database Name: wordpress
Database User: wordpress
Database Password: wordpress

Note: These containers will bind volume so users are requested to provide volume names for both containers.

Thanks for reading this article. We hope it will be useful to implement the Automatic Docker Container Creation Via Linux Bash Script.

Senthilnathan