cai dat docker, docker-compose

TQH 2022-12-09 19:32:12

#!/bin/bash
      #Khởi tạo cài đặt ban đầu
      sudo apt-get update -y
      sudo apt install unzip -y
      sudo apt install net-tools -y

      # cài aws cli
      curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
      unzip awscliv2.zip
      sudo ./aws/install

      #Cài Nginx server
      sudo apt install nginx -y
      cd /var/www/html
        
      #cai dat docker, docker-compose
        

      sudo apt-get install \
            ca-certificates \
            curl \
            gnupg \
            lsb-release
            
      curl -fsSL https://get.docker.com -o get-docker.sh
      DRY_RUN=1 sh ./get-docker.sh
      sudo sh get-docker.sh
      sudo usermod -aG docker ubuntu
        
      sudo apt-get install docker-ce docker-ce-cli containerd.io -y
        
        
      sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      sudo chmod +x /usr/local/bin/docker-compose
        
      sudo chmod 666 /var/run/docker.sock
        
      # cai dat web-server
      echo "<html>" > index.html
        
      echo "<h1>Welcome to CodeStar</h1>" >> index.html
      echo "<h4>You are running instance from this IP (This is for testing purpose only, you should not public this to user):</h4>"
        
      echo "<br>Private IP: " >> index.html
      curl http://169.254.169.254/latest/meta-data/local-ipv4 >> index.html
        
      echo "<br>Public IP: " >> index.html
      curl http://169.254.169.254/latest/meta-data/public-ipv4 >> index.html 
        
      echo "</html>" >> index.html

----------------------------------------

#!/bin/bash
      #Khởi tạo cài đặt ban đầu
      sudo apt-get update -y
      sudo apt install unzip -y
      sudo apt install net-tools -y

      # cài aws cli
      curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
      unzip awscliv2.zip
      sudo ./aws/install

      #Cài Nginx server
      sudo apt install nginx -y
      cd /var/www/html
        
      #cai dat docker, docker-compose
        

      sudo apt-get install \
            ca-certificates \
            curl \
            gnupg \
            lsb-release
            
      curl -fsSL https://get.docker.com -o get-docker.sh
      DRY_RUN=1 sh ./get-docker.sh
      sudo sh get-docker.sh
      sudo usermod -aG docker ubuntu
        
      sudo apt-get install docker-ce docker-ce-cli containerd.io -y
        
        
      sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      sudo chmod +x /usr/local/bin/docker-compose
        
      sudo chmod 666 /var/run/docker.sock
      #install mysql 
      apt-get install -y mysql-server

      git clone https://github.com/buingocanhkma/docker-learning.git
      
      git clone https://github.com/buingocanhkma/codestar.git
      # cai dat web-server
      echo "<html>" > index.html
        
      echo "<h1>Welcome to CodeStar</h1>" >> index.html
      echo "<h4>You are running instance from this IP (This is for testing purpose only, you should not public this to user):</h4>"
        
      echo "<br>Private IP: " >> index.html
      curl http://169.254.169.254/latest/meta-data/local-ipv4 >> index.html
        
      echo "<br>Public IP: " >> index.html
      curl http://169.254.169.254/latest/meta-data/public-ipv4 >> index.html 
        
      echo "</html>" >> index.html