Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC309 Lecture 23

CSC309 Lecture 23

Software Engineering II
Docker
(202406)

Javier Gonzalez-Sanchez

March 14, 2023
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs CSC 309 Software Engineering II Lecture 23: Containers Dr.

    Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227
  2. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    3 MQTT https://github.com/CSC3100/MQTT
  3. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    4 Pong https://github.com/CSC3100/Pong-Game
  4. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    10 § Containers share the host operating system kernel, libraries, and binaries. § Virtual machines run its own guest operating system, § Virtual machines provide full-blown virtualization of hardware resources, including CPU, memory, storage, and networking. It is not VM
  5. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    12 Docker | Steps 2. A package that includes everything needed to run software, including the code, runtime, libraries, dependencies, and configuration files. 3. A container is a runtime instance of an image. It encapsulates the execution environment for a specific application or process, including the filesystem, environment variables, network settings, and runtime options. 1. A text file that contains instructions for building a Docker image
  6. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    22 Dockerfile https:/ /docs.docker.com/reference/dockerfile/
  7. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    30 FROM ubuntu:20.04 # Install Java RUN apt-get update && apt-get install -y openjdk-20-jdk # Install MySQL RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server # Copy the application JAR file COPY target/your-app.jar /app/your-app.jar # Copy the initialization SQL script COPY init.sql /docker-entrypoint-initdb.d/init.sql # Set the working directory WORKDIR /app # Expose ports EXPOSE 3306 Dockerfile
  8. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    31 # Environment variables for MySQL ENV MYSQL_ROOT_PASSWORD=root ENV MYSQL_DATABASE=yourdbname # Start MySQL and the Java application CMD service mysql start && \ sleep 10 && \ mysql -u root -proot yourdbname < /docker-entrypoint-initdb.d/init.sql && \ java -jar /app/your-app.jar Dockerfile
  9. jgs

  10. jgs CSC 309 Software Engineering II Lab 20: MQTT Pong

    Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
  11. jgs CSC 309 Software Engineering II Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Winter 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.