前言
本文基于Centos 7 环境的docker搭建操作,centos 7 用 firewalld 替换了iptables作为默认防火墙操作,但以前习惯了iptables 就不与时俱进了。
环境准备
systemctl disable firewalld
systemctl stop firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
yum install iptables iptables-services net-tools vim
systemctl enable iptables
systemctl start iptablesiptables -A INPUT -p tcp --dport 80 -j ACCEPTiptables-save > /etc/sysconfig/iptables
systemctl restart iptables.service
yum -y install epel-release
Docker 安装
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-compose
systemctl enable docker
systemctl start docker
docker pull wordpress
docker pull mysql:5.7### 运行mysql
mkdir -p /opt/data/apps/wordpress/data
chown -R 999:999 /opt/data/apps/wordpress/datadocker run --name mysql -h mysql --restart=always -e MYSQL_ROOT_PASSWORD=12345678 \
-v /opt/data/apps/wordpress/data:/var/lib/mysql \
-v /opt/data/temp:/opt/soft \
-d mysql:5.7### 运行wordpress
mkdir -p /opt/data/apps/wordpress/webapps
chown -R 33:33 /opt/data/apps/wordpress/webappsdocker run -h wordpress --name wordpress --restart=always --link mysql:mysql -p 80:80 \
-v /opt/data/apps/wordpress/webapps:/var/www/html \
-v /opt/data/temp:/opt/soft \
-d wordpress