Docker 실습내용 메모장

2022-04-11

image-20220411164626553.png

  • VM 내부망 세팅 IP > 192.168.56.101
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
 
docker inspect "컨네이너명" | grep IPAddress

2022.04.12

<html>
 <head>
  <title>Amazon ECS Sample App</title>
   <style>body {margin-top: 40px; background-color: #333;} </style>
  <meta http-equiv="refresh" content="3" >
 </head>
 <body>
  <div style=color:white;text-align:center>
   <h1> Docker Container Web Application. </h1>
   <h2> Great Works! </h2>
    <p>Application is now good running on a container in Docker.</p>
  </div>
 </body>
</html>
from http.server import BaseHTTPRequestHandler, HTTPServer
port = 8900
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-Type', 'text/html; charset=utf-8')
        self.end_headers()
        self.wfile.write('<h1>[Python Web Server running~]</h1>'.encode('utf-8'))
 
httpd = HTTPServer(('0.0.0.0', port), SimpleHTTPRequestHandler)
print(f'Server running on port:{port}')
httpd.serve_forever()
 
 
from random import shuffle
from time import sleep
gamenum = input('로또 게임 회수를 입력하세요: ')
for i in range(int(gamenum)):
   balls = [x+1 for x in range(45)]
   ret = []
   for j in range(6):
      shuffle(balls)
      number = balls.pop()
      ret.append(number)
   print('로또번호[%d]: ' %(i+1), end='')
   print(ret)
   sleep(1)
 

2022.04.14

오후수업 메모장내용 docker multi 빌드

package main
 
import (
        "fmt"
        "os"
        "log"
        "net"
        "net/http"
)
func gohandler(w http.ResponseWriter, r *http.Request){
    name, err := os.Hostname()
    if err != nil {
         fmt.Printf("error: %v\n", err)
         return
    }
    fmt.Fprintln(w, "hostname: ", name)
 
    addr, err := net.LookupHost(name)
    if err != nil {
         fmt.Printf("error: %v\n", err)
         return
    }
    fmt.Fprintln(w, "IP: ", addr)
}
func main() {
    fmt.Fprintln(os.Stdout, "Go!!! Go Application ......")
      http.HandleFunc("/", gohandler)
      log.Fatal(http.ListenAndServe(":9090",nil))
}