Skip to main content

Command Palette

Search for a command to run...

Write a Docker File

Published
1 min read
Write a Docker File
S

DevOps enthusiast sharing real-world insights. 🚀 #Automation #CI/CD #InfrastructureAsCode

Task Requirement :

As per recent requirements shared by the company's application development team, they need custom images created for one of their projects. Several of the initial testing requirements are already been shared with the DevOps team. Therefore, create a docker file /opt/docker/Dockerfile (please keep D capital of Dockerfile) on App server 3 in the Datacenter and configure it to build an image with the following requirements:

  • Use ubuntu as the base image.

  • Install apache2 and configure it to work on the 5000 port. (do not update any other Apache configuration settings like document root etc).

Execution :

Here's a step-by-step guide to creating and saving the Dockerfile.

  • SSH into App Server 3

    ssh your_username@app_server_2_ip

  • Navigate to the /opt/docker/ directory

    cd /opt/docker/

  • Create the Dockerfile using a text editor

    sudo vi Dockerfile

Now, you have the Dockerfile in the specified location. You can build the Docker image using the following command.

docker build -t custom-apache-image /opt/docker/

After the image is built, you can run a container based on this image.

docker run -p 5000:5000 -d custom-apache-image

More from this blog

DevOps Task Diaries

19 posts

Welcome to my DevOps documentation blog! I'm Samson Oladipo, and I'm passionate about sharing real-world DevOps scenarios, experiences, and best practices with the global tech community.

Join me on this DevOps journey as we explore the fascinating world of IT operations and software development, one task at a time. Whether you're a seasoned pro or just beginning your DevOps adventure, you'll find valuable insights and practical guidance to help you succeed in your own DevOps endeavors.