Programming in PHP Docker environment (1) --- Centos7 operating system

PHP is a popular programming language used to create dynamic websites and applications. Docker is an open source platform that helps users easily create, deploy and run various applications.

Step 1: Install Docker

In order to build a Docker environment on CentOS, we need to install Docker first. Enter the following command in the terminal to install:

#安装Docker
 
sudo yum install docker-ce docker-ce-cli containerd.io

After the installation is complete, start the Docker service:

#启动docker服务
 
sudo systemctl start docker

Step 2: Download the PHP image from the Docker repository

Multiple versions of PHP images can be downloaded from the Docker repository, and we choose the latest version. Enter the following command in the terminal to download:

#拉取最新版本php镜像
 
sudo docker pull php:latest

After the download is complete, let's check the list of successfully downloaded mirrors:

#查看镜像列表
 
sudo docker images


Step 3: Create a PHP development environment

Running a container in Docker is equivalent to creating an independent virtual machine, and we can build an independent PHP development environment in the container.
Create a container named my-php-dev:

#在容器中创建一个php容器 (容器名:my-php-dev)
 
sudo docker run -it --name my-php-dev -p 8080:80 -v /home/dev:/var/www/html php:l

おすすめ

転載: blog.csdn.net/pengmeitao/article/details/130283618