在阿里云centos6.5系统上用docker搭建php环境的失败过程

博主尝试在阿里云的CentOS6.5系统上使用Docker搭建PHP环境,但遭遇失败。遇到的问题包括在容器内无法使用netstat命令。最终决定将系统更换为Ubuntu,并计划继续尝试搭建。
摘要由CSDN通过智能技术生成

1.
下载官方的一个版本的centos
docker pull torusware/speedus-centos
2.
[root@*********** ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>              <none>              e29858c6c978        3 days ago          215.7 MB
3.
docker run -it e298 /bin/bash
cd ~
mkdir Downloads
(ctrl+D)
4.
docker ps -l
[root@*********** ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
a5fb48538a85        e29858c6c978        "/bin/bash"         7 minutes ago       Exited (0) 3 minutes ago                       serene_bohr
5. 进入容器:
[root@*********** ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
e2985               latest              304ffdae1987        4 seconds ago       215.7 MB
[root@*********** ~]# docker run -it 304f /bin/bash
yum install wget unzip tar
6.更新阿里云的源:
[1] 首先备份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[2] 进入yum源配置文件所在文件夹
[root@localhost yum.repos.d]# cd /etc/yum.repos.d/
[3] 下载163的yum源配置文件,放入/etc/yum.repos.d/(操作前请做好相应备份)
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
[4] 运行yum makecache生成缓存
[root@localhost yum.repos.d]# yum makecache
[5] 更新系统
[root@localhost yum.repos.d]# yum -y update
7.用ezhttp搭建环境:
cd ~/Downloads
wget --no-check-certificate https://github.com/centos-bz/EZHTTP/archive/master.zip -O EZHTTP.zip
unzip ./EZHTTP.zip
cd ./EZHTTP-master/
chmod +x ./start.sh
./start.sh
(就此,按需要安装上相关的程序)
8.提交
[root@*********** ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
2ffd5e5b899d        e2985:latest        "/bin/bash"         58 minutes ago      Exited (1) About a minute ago                       jolly_sinoussi
[root@*********** ~]# docker commit -m 'commitProject' 2ffd5 e2985
e770319ae86b2e9a1994ba1910fb41ac0af3fae0d741150a793c20065c7beba5
[root@*********** ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
e2985               latest              e770319ae86b        4 minutes ago       4.903 GB
9.重启:
[root@*********** ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
cebca558174e        e2985:latest        "/bin/bash"         4 minutes ago       Exited (0) 1 seconds ago                       admiring_almeida
[root@*********** ~]# docker restart admiring_almeida
docker run -it 304f /bin/bash
10.安装git
yum install git
(ctrl + d)
docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                      PORTS               NAMES
33d3c032a5ec        304ffdae1987        "/bin/bash"         About a minute ago   Exited (0) 22 seconds ago                       kickass_franklin
docker commit -m 'commitProject' 33d3c032a5ec 'test'
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
test                latest              a553d6039e89        About a minute ago   319 MB
e2985               latest              e770319ae86b        3 hours ago          4.903 GB
docker run -it test /bin/bash
git --version
git version 1.8.3.1
(出现上一行内容,说明刚才的修改生效)
11.安装php
yum install wget unzip tar
wget https://github.com/centos-bz/EZHTTP/archive/master.zip -O EZHTTP.zip
unzip EZHTTP.zip
cd EZHTTP-master
chmod +x ./start.sh
docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
a2e33648337e        test:latest         "/bin/bash"         51 minutes ago      Exited (0) About a minute ago                       adoring_swartz
docker commit -m 'commitProject' a2e33648337e 'test'
上一步是提交安装好了PHP之后的代码进入工程
[root@*********** Downloads]# docker commit -m 'commitProject' a2e33648337e 'test'
FATA[0182] Error response from daemon: ApplyLayer exit status 1 stdout:  stderr: write /usr/local/mysql/lib/libmysqld.a: read-only file system
出错了。
重启容器
 
12.docker pull ubuntu
Pulling repository ubuntu
fa81ed084842: Error pulling image (14.04) from ubuntu, Driver devicemapper failed to create image rootfs e118faab2e16f9d858fcec0d86c9148e9b0fa021697239745f3253f367941dcc: Error running DeviceCreate (createSnapDevice) dm_task_run failed reate (createSnapDevice) dm_task_rFATA[0041] Error pulling image (14.04) from ubuntu, Driver devicemapper failed to create image rootfs e118faab2e16f9d858fcec0d86c9148e9b0fa021697239745f3253f367941dcc: Error running DeviceCreate (createSnapDevice) dm_task_run failed
全部删除。
docker rmi -f $(docker images -q)
删除所有镜像。
从头运行一遍就能删除所有的镜像了。
但删除了依然失败。

最后的决定:换centos成为ubuntu系统。明天继续努力再搭建看看。


请教各位朋友:如何能在centos上搭建一个成功的docker环境,在容器里用netstat也不能用。多谢:)



 
参考:
http://www.linuxidc.com/Linux/2014-09/106322.htm
http://bbs.aliyun.com/read/151413.html
http://blog.csdn.net/Raptor/article/details/18305299
http://www.cnblogs.com/lightnear/archive/2012/10/03/2710952.html
http://blog.chinaunix.net/uid-14010457-id-4109433.html
http://segmentfault.com/a/1190000000751601
http://blog.chinaunix.net/uid-10915175-id-4443127.html
http://blog.csdn.net/vovo2008/article/details/14164299
http://www.linuxidc.com/Linux/2014-09/106322.htm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值