Dockerfile
FROM
FROM eclipse-temurin:17
ADD and COPY
COPY: copy files from the system to the container
ADD: same as COPY but also can unzip archives and accept urls
COPY <system-src-path> <docker-dest-path>
ADD <system-src-path> <docker-dest-path>
RUN
# Shell form
RUN npm start
# Exec form, preferred
RUN ["npm", "start"]
EXPOSE
EXPOSE 8090
WORKDIR
WORKDIR /tmp
ENV
- Set environment variables:
ENV AXDIR /fitnesse
ENV SPRING_PROFILES_ACTIVE=prod
ARG
- defines build time environment variables
- Running containers do not have access to the variables
- should not be used for sensitive data since
docker history can reveal the variables
ARG variable=value
CMD and ENTRYPOINT
- Both accepts shell and exec forms
CMD: runtime command
CMD ["echo", "hello"]
ENTRYPOINT: runtime command prefix
- In the following example, you can run:
docker run <image> hello to execute echo hello
ENTRYPOINT ["echo"]