编程知识 cdmana.com

Docker pit entry

Boot on virtual machine docker Containers , Personally, it's a little obsessive-compulsive , It's not a good reason to install virtual machine software on the new computer , I suddenly remembered that I had a notebook , So the virtual machine is installed

Strangely, I need to connect this virtual machine from another computer , So I need to connect to the current virtual machine through a LAN So we need to do it like this

First : Change the network adapter of the virtual machine , Will be original NTA Change the connection mode to bridge mode

ifconfig View the address of the virtual machine

docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:8bff:fea2:8719  prefixlen 64  scopeid 0x20<link>
        ether 02:42:8b:a2:87:19  txqueuelen 0  (Ethernet)
        RX packets 132  bytes 71503 (69.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 162  bytes 15191 (14.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.102  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::8b76:af99:4f90:7e57  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:89:1c:07  txqueuelen 1000  (Ethernet)
        RX packets 318704  bytes 364897092 (347.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 168588  bytes 18499531 (17.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 68  bytes 5912 (5.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5912 (5.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethb91c37a: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::6cd6:56ff:fe0e:c5a2  prefixlen 64  scopeid 0x20<link>
        ether 6e:d6:56:0e:c5:a2  txqueuelen 0  (Ethernet)
        RX packets 81  bytes 68963 (67.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 101  bytes 10364 (10.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

It is obvious that the address of my current virtual machine is 192.168.1.102 Use Xshell Just connect the tools

So here's the point , How to run on the current virtual machine tomcat Containers , Under the condition of ensuring that your virtual machine environment is normal , install docker. Simple things directly Baidu , Don't focus on

Cough , On the blackboard , Focus on taking notes !

Download mirroring

$ docker pull tomcat

Look at the mirror image

$ docker images
  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
  tomcat              latest              d5eef28cf41d        41 hours ago        647MB

Start the mirror ( Background operation )

$ docker run -p 8080:8080 -d tomcat
a580ba060ccd9df5cfd3c692159858bab7d4b1d8a6c888d61e3465295d3b2b25

If no error is reported in this step, it indicates that the startup is successful

View the running image

$ docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
a580ba060ccd        tomcat              "catalina.sh run"   16 minutes ago      Up 16 minutes       0.0.0.0:8080->8080/tcp   epic_murdock
//  The running image can be through  $ docker ps -a  see 

visit http://192.168.1.102:8080/ You can see tomcat Cat interface

Another case is the image access 404

terms of settlement :

$ docker exec -it  Containers id /bin/bash`* 

Current Containers id I just started tomcat Of id, Can pass docker ps see

$ docker exec -it a580ba060ccd /bin/bash
root@a580ba060ccd:/usr/local/tomcat# 

determine webapps There are no documents

$ rm -rf webapps
$ mv webapps.dist webapps

Refresh the page to see tomcat Feline

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[Shao Jie]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/08/20210809183600787N.html

Scroll to Top