如何快速用docker搭建一個php7的開發環境

編寫Dockerfile


FROM centos:7php

RUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \mysql

&& wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo \linux

&& yum install epel-release -y \nginx

# 安裝經常使用工具web

&& yum install -y nginx gcc uuid libuuid vim tar curl rsync bzip2 iptables tcpdump less telnet net-tools lsof sysstat \redis

&& rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \sql

# 安裝mem redisdocker

&& yum install -y memcached redis \vim

# 安裝php7 以及經常使用擴展centos

&& yum -y install php70w php70w-cli php70w-fpm php70w-pdo php70w-devel php70w-common  php70w-mysqlnd php70w-opcache php70w-pecl-redis php70w-pecl-xdebug php70w-xml php70w-pecl-memcached \

# 安裝mysql5.7

&& wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm \

&& rpm -ivh mysql57-community-release-el7-9.noarch.rpm \

&& cd  /etc/yum.repos.d/ \

&& yum -y install mysql-server

EXPOSE 22

CMD ["/bin/bash」]


上面的命令集,安裝了linux經常使用的工具,php7以及php7經常使用擴展,memcached, redis 等

構建鏡像

docker build -t yoursDockerName .

而後

docker run xxx 愉快的玩耍吧

須要注意的是添加幾個參數:

docker中每次指定了hostname,重啓會失效,因此,咱們在run時指定好

--add-host localhost:172.17.0.2 --hostname localhost

使container內的root擁有真正的root權限

--privileged=true
相關文章
相關標籤/搜索