-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathwordpress-docker.sh
executable file
·27 lines (22 loc) · 1.33 KB
/
wordpress-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
printf "\n--- bring the official MySQL & WordPress docker images ---\n"
docker pull mysql
docker pull wordpress
printf "\n--- stop previous containers and remove them, if there are any ---\n"
mysqldocker_id=$(docker ps -a | grep mysqldocker | cut -d' ' -f1)
docker stop $mysqldocker_id
docker rm $mysqldocker_id
mywordpressdocker_id=$(docker ps -a | grep mywordpressdocker | cut -d' ' -f1)
docker stop $mywordpressdocker_id
docker rm $mywordpressdocker_id
printf "\n--- start the new containers (MySQL and WordPress) ---\n"
docker run --name mysqldocker -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest
mywordpressdocker_id=$(docker run -e WORDPRESS_DB_PASSWORD=my-secret-pw -d --name mywordpressdocker --link mysqldocker:mysql wordpress)
printf "\n--- add the custom changes to the WordPress container ---\n"
docker exec -it $mywordpressdocker_id apt-get update
docker exec -it $mywordpressdocker_id apt-get -y install vim
docker exec -it $mywordpressdocker_id apt-get -y install git
docker exec -it $mywordpressdocker_id sed -i '$ a\php_flag opcache.enable Off' /var/www/html/.htaccess
printf "\n--- find out the IP address of the WordPress container ---\n"
ip_address=$(docker inspect mywordpressdocker | grep '"IPAddress":' | head -1 | cut -d'"' -f4)
echo 'Go to: http://'$ip_address'/ in order to install a new WordPress site.'