安装docker
这个忘了怎么安装的,想起来再写
docker下安装php74、php7.4
#拉取php74的镜像
docker pull php:7.4.30-fpm-buster
#查看镜像列表
[root@server]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php 7.4.30-fpm-buster c2b55dc06eee 7 days ago 386MB
#启动php镜像
[root@server]# docker run --name phpweb -v /home/user:/data -p 8080:8080 -d php:7.4.30-fpm-buster
2f66a25eabf7ab887ae8024ca43678f9c5d0e1d8430e47cdaa9d1bf3961b640b
#查看状态
[root@server]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de1423308601 php:7.4.30-fpm-buster "docker-php-entrypoi…" 15 seconds ago Up 14 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 9000/tcp phpweb
#这个时候容器就启动了,我们可以进入容器看看
[root@server]# docker exec -it phpweb /bin/bash
root@de1423308601:/var/www/html# pwd
/var/www/html
root@de1423308601:/var/www/html# cd /
root@de1423308601:/# ls
bin boot data dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@de1423308601:/# cd data/
root@de1423308601:/data# ls
LICENSE.txt README.md
root@de1423308601:/data# php -v
PHP 7.4.30 (cli) (built: Aug 23 2022 15:35:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
至此完结,以上 -v /home/user:/data的意思是把主机/home/user挂载到容器的data目录。--name容器命名;-p则将虚拟机8080端口和本地8080端口绑定,-d则后台运行
停止容器:docker stop phpweb
删除容器:docker rm phpweb
启动容器:docker start phpweb
如果pull很慢或者报错TLS则输入这条命令试试
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
该命令转自https://blog.csdn.net/qq_41446245/article/details/125822443
标签:8080,data,笔记,de1423308601,使用,docker,php,root From: https://www.cnblogs.com/xfstu/p/16644823.html