Linux Containers
⏱
4 mins remaining
Dockerfiles
Dockerfiles. How to make an image ?
A Dockerfile is a script used to build a Docker image. It contains a set of instructions that Docker uses to automatically create a containerized environment for a specific application. Docker images are a lightweight, standalone, and executable package that includes everything needed to run an application, including the code, runtime, libraries, and system tools.
How do Dockerfiles work ?
Example 1:
FROM eclipse-temurin:17-jdk-jammy
WORKDIR /app
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
RUN ./mvnw dependency:resolve
COPY src ./src
CMD ["./mvnw", "spring-boot:run"]
Example 2:
FROM node:10-alpine
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY package*.json ./
USER node
RUN npm install
COPY --chown=node:node . .
EXPOSE 8080
CMD [ "node", "app.js" ]
Assignment
- Build a php Dockerfile for our
info.phpfile.