运行centos容器
安装centos:
sudo docker pull centos
开启容器:
-p端口映射
-d后台运行
-v目录映射 本地数据:容器数据
docker run -p 80:80 -p 8888:8888 -i -d -v /opt/centos:/centos -t centos /bin/bash
进入:
docker exec -it containerId bash
停止:
docker stop containerId // containerId 是容器的ID
使用docker环境搭建lamp环境
lamp和资源文件全部映射到物理机 lamp环境使用bitnami-lampstack-7.1.19-1-linux-x64-installer.run 安装lamp选择安装到/centos/lampstack-7.1.19-1
docker run -p 80:80 -p 3306:3306 -i -d -v /home/lxx/centos:/centos -t centos /bin/bash• 1
进入
docker exec -it CID bash• 1
进入/centos/lampstack-7.1.19-1(即物理机/home/lxx/centos) mysql默认端口3306
./ctlscript.sh ?
usage: ./ctlscript.sh help
./ctlscript.sh (start|stop|restart|status)
./ctlscript.sh (start|stop|restart|status) mysql
./ctlscript.sh (start|stop|restart|status) apache
help - this screen
start - start the service(s)
stop - stop the service(s)
restart - restart or start the service(s)
status - show the status of the service(s)• 1
进入phpmyadmin
phpmyadmin.example.com• 1
如果docker启动失败提示:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/vhs/mysql-8.0.11-0/mysql/tmp/mysql.sock' (2)• 1
解决方案(不一定有效)
#文件/vhs/mysql-8.0.11-0/mysql/tmp/mysql.sock.lock被锁住了,改为/vhs/mysql-8.0.11-0/mysql/tmp/mysql.sock
mv /vhs/mysql-8.0.11-0/mysql/tmp/mysql.sock.lock /vhs/mysql-8.0.11-0/mysql/tmp/mysql.sock
#启动
/vhs/mysql-8.0.11-0/mysql/bin/mysqld --user=root
/vhs/mysql-8.0.11-0/ctlscript.sh start mysql