docker farewell cross-system installed trouble

docker function is very flexible, but requires some learning before they can flexibly

But given the reader may not come into contact docker
we direct method gives a command to install ubuntu system

docker run -it   --rm -p 9090:80  registry.cn-hangzhou.aliyuncs.com/mkmk/desktop:ubuntu1804

The machine then visit
localhost: 9090 you can experience the system, you can use the command-line version of the system under test

#三个命令都是查看版本号的
cat /proc/version

uname -a

lsb_release -a

Here Insert Picture Description

Here is not over, because the system just did 9090-80 mapping, that if we want to run a nginx in a virtual machine, or publish a web application, then how to do it
let us step by step to realize it

#注意 这些命令要在windows 管理员权限下运行,
docker network create --driver bridge --subnet 10.10.0.0/16  --gateway 10.10.0.1 mynet10

route add 10.10.0.0 mask 255.255.0.0 10.0.75.2

docker run -it   --rm   --net mynet10  --ip  10.10.10.5   --name ubuntu2      registry.cn-hangzhou.aliyuncs.com/mkmk/desktop:ubuntu1804

At this visit
10.10.10.5
Here Insert Picture Description

Such container system will have their own port
and then take a look at the vessel can run nginx
Here Insert Picture Description
I wanted to install nginx result has been, but 80 ports are occupied.
Therefore, we modify the configuration file under nginx

打开/etc/nginx/nginx.conf
修改内容如下
!!!!!!!!!!!!!1
user www-data;
worker_processes 1;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
	# multi_accept on;
}

http {
	
	 server {
        listen      48880 ;
        server_name  _;
        root         /usr/share/nginx/html;
        include /etc/nginx/default.d/*.conf;
        location / {
        }
        error_page 404 /404.html;
            location = /40x.html {
        }
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	include /etc/nginx/mime.types;
	default_type application/octet-stream;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;
	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;
	gzip on;
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}

Save the file after the modification is completed

终端执行
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

再执行
nginx -s reload
就可以访问 ubuntu中的nginx服务了
服务运行在
http://10.10.10.5:48880/

Here Insert Picture Description
You can also do a lot of things that you like in this container!

Published 72 original articles · won praise 1 · views 3419

Guess you like

Origin blog.csdn.net/qq_43373608/article/details/103938922