Docker practice web applications-create, configure, and manage Nginx images and containers

Source: Internet
Author: User
Tags ssh centos docker ps docker run

1. Search for the system image and create a container.
Here we docker ps | grep centos to see that there is a centos7-ssh image we have previously created (the ssh service has been built inside), if not, you can download a linux system image by yourself.

Docker run-ASD -- name nginx-ssh-centos-p 22022:22 centos7-ssh
After the container is created, we remotely enter the container through ssh to Configure nginx.

2. Build nginx containers
As for the establishment of containers, we will not demonstrate it here, just like configuring nginx in common systems. I have also written an article about installing nginx before. For more information, see how to install nginx environment configuration in linux. After the installation, the effect starts. The container is displayed as follows:

[Root @ 21 yunwei ~] # Docker exec-ti nginx-ssh-centos/bin/bash
[Root @ cdfe6ebbf960/] # netstat-tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Tcp 0 0 0.0.0.0: 22 0.0.0.0: * LISTEN-
Tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN 27/nginx: master pr
Tcp6 0 0: 22: * LISTEN-
Access via a browser is successful:
3
3. Submit the image.
Through the container nginx-ssh-centos that has just been created, we submit an image named nginx-ssh-centos7

[Root @ 21 yunwei ~] # Docker commit nginx-ssh-centos nginx-ssh-centos7: 201671
[Root @ 21 yunwei ~] # Docker images | grep nginx-ssh-centos7
Nginx-ssh-centos7 201671 1dda6535c3fe 1 days ago 496.1 MB
So far, image construction is complete. Later we can build a container through the nginx-ssh-centos7: 201671 image, the build of the container will bring the ssh service and nginx.
For other services, you can configure them by yourself, such as setting up services such as mysql, tomcat, and redis. The production steps are basically the same.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.