Create a Docker File
As per recent requirements shared by the Nautilus application development team, they need custom images created for one of their projects. Several of the initial testing requirements are already been shared with DevOps team. Therefore, create a docker file /opt/docker/Dockerfile (please keep D capital of Dockerfile) on App server 2 in Stratos DC and configure to build an image with the following requirements:
Steps
Dockerfile
Good to Know?
Dockerfile Fundamentals
- Purpose: Text file with instructions to build Docker images
- Automation: Reproducible image creation process
- Layered: Each instruction creates a new layer
- Caching: Docker caches layers for faster builds
Common Dockerfile Instructions
- FROM: Base image to start from
- RUN: Execute commands during build
- COPY/ADD: Copy files from host to image
- WORKDIR: Set working directory
- EXPOSE: Document which ports the container uses
- CMD/ENTRYPOINT: Default command when container starts
Best Practices
- Minimal Base: Use smallest possible base image
- Layer Optimization: Combine RUN commands to reduce layers
- Cache Efficiency: Order instructions by change frequency
- Security: Don’t run as root, use specific versions
Apache in Docker
- Port Configuration: Modify default port 80 to custom port
- Configuration Files: Update httpd.conf for custom settings
- Document Root: Set appropriate web content directory
- Process Management: Ensure Apache runs in foreground