Outline
As a front-end, I feel the need to learn to use docker dry the following things:
- Deployment of front-end applications
- Nginx deployment
- To deploy nginx with https
- Use docker compose for deployment
- Nginx add to redis
- Use kubernetes
Here I follow the rhythm eleven research again, the experience recorded for later reference when developing, we believe it is useful to others.
References:
Nginx deployment
1. pull nginx mirror. Enter the following command remote pull the latest version of nginx mirror.
docker pull nginx:latest
2. Establish Dockerfile file in your home directory front-end project, write the following:
FROM nginx
3. Generate Mirror
docker build -t docker-nginx:latest .
4. Run image instance
docker run -d -p 2002:80 docker-nginx
5. Finally Open localhost: 2001 to see nginx standard welcome screen.
Do something
If we want to customize docker nginx configuration file inside it?
1. We enter docker-nginx container bash interface
docker exec -it [container_id] /bin/bash
2. Check the nginx configuration folder path
nginx -t
// 输出如下内容
// nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
// nginx: configuration file /etc/nginx/nginx.conf test is successful
You can see the configuration files in /etc/nginx/nginx.conf.
3. Check the contents of the configuration file
cat /etc/nginx/nginx.conf
// 在最下面可以看到这么一段
// include /etc/nginx/conf.d/*.conf;
In the bottom you can see such a period include /etc/nginx/conf.d/*.conf;
, that is to say, vice configuration file in the /etc/nginx/conf.d/default.conf. We intend to rewrite the deputy profile.
4. rewritten Dockerfile file as follows:
FROM nginx
COPY default.conf /etc/nginx/conf.d/default.conf
In other words, replace docker inside default.conf with default.conf files in the current directory.
5. Finally image regenerate again and run to the container.
Note: The method I have here is not optimal , as well as mount configuration files, use docker compose method is much better than this, later introduced.