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

CSC509 Lecture 12

CSC509 Lecture 12

Software Design
Docker
(202411)

Javier Gonzalez-Sanchez

November 14, 2024
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 508/9 Software Engineering (Design & Deployment) Lecture 12. Docker
  2. It is not VM • 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. 5
  3. Docker | Steps 7 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
  4. 15

  5. 16

  6. 17

  7. Docker f ile 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 25
  8. Docker f ile # 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 26
  9. CSC 509 Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected] Fall 2024

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