DevOps Classroom Series – 05/Sept/2021

Viewing Docker Logs

  • docker container logs can be viewed by the command docker container logs <container name>
  • All the logs and errors redirected to STDERR and STDOUT stream
  • Docker supports different logging drivers Refer Here

Constraints on Docker containers

  • By default docker container has no resource restrictions and it can use as much of resources given by the host kernel
  • We can restrict memory and cpu while starting a container
docker container run --name memjenkins -P -d --memory 1024m jenkins/jenkins
  • now execute docker stats Preview
  • similarly
    • –memory-swap
    • –memory-reservation
    • –memory-swappiness
  • We can also restrict cpu’s as well
docker container run --name memcpujenkins -P -d --memory 1024m --cpus="2" jenkins/jenkins

Game of life multi stage build

  • Docker file
FROM maven:3-openjdk-8 as builder
RUN git clone && cd game-of-life && mvn package

FROM tomcat:9.0-jdk8
COPY --from=builder /game-of-life/gameoflife-web/target/gameoflife.war /usr/local/tomcat/webapps/gameoflife.war

Using ENV in CMD

  • Dockerfile
FROM ubuntu
CMD ["/bin/bash", "-c", "sleep ${DURATION}"]


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin