- Building a docker image
- Write a Dockerfile
- Build a docker image
- Running containers
- Running and stopping containers
- Exposing ports and
- Mouting volumens for data persistence
- Application configuration
- Log management
- Persistent storage
- File uploads
- Dev environments
- Data backup
- Data sharing
- Env variables and configuration
- Containers management
- Running containers
- Inspect containers
- Delete containers and images
- Docker compose
- docker-compose.ym
- Running apps
- Optimization and best practices
- Reduce the container size
- Dockerfile layers
- Security
- CI/CD
- Integrate Docker in CI/CD pipelines
- Integrate Docker with Github Actions
- Networking in Docker
- Communication among containers
- Docker Swarm and Kubernetes
- Osquestating with Docker Swarm
- Kubernetes for advanced orchestration
- Docker on production
- Deployment strategies
- Logging and monitoring containers
- Having a Dockerfile is mandatory
./mvnw clean packagedocker build -t demo-springboot-docker .docker run -p 8080:8080 demo-springboot-docker- Stop and delete docker container
docker ps -a
docker stop <container id>
docker rm <container id>
- Stop and delete docker images
docker images
docker rmi <image_id>* We are going to mount the volumen where source code will be left. * We will need to add the devtools dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>- We will need to ask spring boot to consider reloading the app
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true- The Dockerfile should avoid using COPY and instead of using java -jar we will use sprint boot command:
FROM ...
WORKDIR ...
EXPOSE ...
ENTRYPOINT ["./mvnw", "spring-boot:run"]- Initial build is mandatory, it will happen just once
docker build -t demo-springboot-docker .- Run the docker container with the mounted volumen
docker run -p 8080:8080 -v $(pwd):/app demo-springboot-dockerdocker ps [-a]
docker inspect [container_id]
docker stop [container_id]
docker start [container-id_or_name]
docker rm [-f] [container_id]
docker images
docker rmi [image_id]
docker container prune [-a]
docker volume prune
docker logs [container_id]
docker exec -it [container_id] /bin/bashFor this simple example and aiming to demonstrate its applicatiblity without adding an extra service like a database, we duplicated the service. Bear in mind that this docker-compose.yml file and the nginx.conf both are develop env oriented just to not complicate the whole example.
- Optimization related to using stages to build the final images.
- Changing the ownership: As shown in the Dockerfile, it was added a group and a new user added to that group, which will be the owner.
It could be csonsidered using Selinux or apparmor.