Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build php-nginx-alpine Image by Docker

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how Docker builds php-nginx-alpine images. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Alpine linux is the basic image

Docker pull gliderlabs/alpine

Alpine linux image address

At present, the latest tag is version 3.8. the image is only 4m in size, which is very compact.

Run Mirror

Docker run-it gliderlabs/alpine

After running, you can see that there is a basic linux file system. There is no demonstration here. Those who are interested can try it on their own.

Install php and nginx

Apk updateapk add php7 nginx

Next, you can continue to install php-related expansion packs or other linux expansion packs according to your needs.

Search for expansion packs, such as the php7 toolkit, through the following instructions:

# apk search php7

Install the php extension

The copy code is 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

Php7 directory: / etc/php7

Nginx directory: / etc/nginx

Start php-fpm and nginx

# create the pid file first, otherwise nginx will not run mkdir / run/nginx touch / run/nginx/nginxpid# first run php, then run nginx/usr/sbin/php-fpm7/usr/sbin/nginx

At this point, you can see that php and nginx are running normally, and the mirror environment is almost complete. Next, you can see how to save this image.

Create a mirror

From another terminal, use docker ps to view the image ID. You can save the image with the following instructions:

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 definition is 0.1

Run the newly generated image

Bind port 8080 to see the effect.

Docker run-it-p 8080 yisonli/php7-nginx-alpine:0.1

After starting php-fpm and nginx manually, the browser can see the effect.

Http://127.0.0.1:8080/index.php

Docker supplementary record

[shared folder]

Docker run-v `pwd` / www:/var/www/html-it-p 808080 yisonli/php7-nginx-alpine:0.1

[delete unrunning containers]

Docker rm $(docker ps-a-Q)

[build an image in Dockerfile]

Docker build-t yisonli/php7-nginx-alpine:0.2.

Build is written as Dockerfile after a little optimization of the process in this paper, and comes with a startup script.

It has been uploaded to Docker Hub for download and research.

[add additional tag tags to the image]

Docker tag 9d9c6030e5e9 test/mytag, thank you for your reading! This is the end of this article on "how to build a php-nginx-alpine image in Docker". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report