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.