Docker (3): configure the rancher network environment and download and start the tomcat container
1. About rancher
The rancher environment was set up last time, but the network was not properly configured.
Container not created successfully. This time, it turns out to be a network problem.
The coreos installed in virtualbox is not configured with an ip address, causing network access failure.
The agent is not successfully registered and has no host environment. You cannot create a docker application.
2. Configure the network
If the network environment of virtualbox is not configured, the network is a nat environment. In this case, set the master site to 10.0.2.15.
This is the nat ip address allocated by virtualbox, but the network cannot communicate with external users.
You can only use port forwarding. If you want to place coreos in the Intranet environment, you need to use a bridge network:
Then configure the IP Address: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwcmUgY2xhc3M9 "brush: SQL;"> Vi/etc/systemd/network/static. network # edit the file: [Match] Name = eth0 # It is the Name of the NIC [Network] Address = 192.168.2.196Gateway = 192.168.2.1DNS = 192.168.2.1DNS = 114.114.114.114
Then restart the service:
systemctl restart systemd-networkd
At this time, the ip address is allocated. It can be accessed through the Intranet.
3. Set host
Add a Host:
First, enter the host IP address. If an error occurs, modify the IP address in the admin menu:
Then add an agent that can be monitored by rancher only after the agent service is available.
Of course, this host is itself.
A super-long id will be generated after the addition, and then you can view it using the docker logs id.
If no problem occurs during startup and docker ps is used, you can see the service.
You can see in host:
4. Create a tomcat container
Create a container:
Enter the tomcat image name, and then map port 9090 to tomcat 8080.
Because rancher already uses port 8080.
Start tomcat. Wait for tomcat to download and start.
After the startup is successful, you can monitor the container:
Tomcat can access:
The Host IP address is added with the mapped port 9090.
4. Summary
Rancher provides powerful functions to create docker in just a few clicks,
It greatly shortens the time and energy for building the environment.
The container running status can be directly monitored. You can create, copy, and migrate containers at any time.
At the same time, complicated docker configurations become super simple.