Although I have run some projects in Docker environment before, I still don’t understand the image very well. In addition, the existing images on the Internet contain too many unused libraries, so I decided to build my own image from scratch. Alpine Linux is the base image docker pull gliderlabs/alpine alpine linux mirror address The latest tag is version 3.8, and the image is only 4M in size, which is very streamlined. Run the image docker run -it gliderlabs/alpine After running, you can see that there is a basic Linux file system. I won’t demonstrate it here, but those who are interested can try it by themselves. Install PHP and nginx apk update apk add php7 nginx Next, you can continue to install PHP-related extension packages or other Linux extension packages according to your needs. To search for extension packages, such as the PHP7 toolkit, use the following command: # apk search php7 Install PHP extension Copy the code as follows: apk add php7-mysqli php7-pdo_mysql php7-mbstring php7-json php7-zlib php7-gd php7-intl php7-session php7-fpm php7-memcached Directory Structure
Start php-fpm and nginx # Create the pid file first, otherwise nginx cannot run mkdir /run/nginx touch /run/nginx/nginxpid # Run php first, then run nginx /usr/sbin/php-fpm7 /usr/sbin/nginx At this point, we can see that PHP and nginx are running normally, and the mirroring environment has been basically completed. Next, let’s see how to save this image. Create an image Open another terminal and use docker ps to view the image ID. The following command can save the image: docker commit -a "yisonli" -m "my first php7-nginx" 9d9c6030e5e9 yisonli/php7-nginx-alpine:0.1 Note: 9d9c6030e5e9 is the image ID, yisonli/php7-nginx-alpine is the saved image name, and the version is defined as 0.1 Run the newly generated image Bind port 8080 to see the effect docker run -it -p 8080:8080 yisonli/php7-nginx-alpine:0.1 After manually starting php-fpm and nginx, the effect can be seen in the browser. http://127.0.0.1:8080/index.php Docker additional records 【Shared folder】 docker run -v `pwd`/www:/var/www/html -it -p 8080:8080 yisonli/php7-nginx-alpine:0.1 Deleting non-running containers docker rm $(docker ps -a -q) [Build an image using Dockerfile] docker build -t yisonli/php7-nginx-alpine:0.2 . 0.2 is built after slightly optimizing the process in this article and writing it into a Dockerfile, and it also comes with a startup script. It has been uploaded to Docker Hub and is available for download and research. Add additional tags to the image docker tag 9d9c6030e5e9 test/mytag The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: js to achieve star flash effects
>>: Vue code highlighting plug-in comprehensive comparison and evaluation
This article example shares the specific code of ...
illustrate: VMware IOInsight is a tool that helps...
Download address: https://dev.mysql.com/downloads...
Table of contents Where are the logs stored? View...
width: auto The child element (including content+...
This article mainly introduces the sql script fun...
Table of contents Linux--File descriptor, file po...
Table of contents 1. Global Guard 1.1 Global fron...
I installed IE8 today. When I went to the Microso...
Table of contents Preface 1. Conventional Vue com...
This article example shares the specific code of ...
Docker is really cool, especially because it'...
1. To develop web responsively, the page must ada...
This article shares a draggable login box impleme...
Problem <br />In responsive layout, we shou...