Write a Docker File

Samson OladipoSamson Oladipo
1 min read

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

0
Subscribe to my newsletter

Read articles from Samson Oladipo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Samson Oladipo
Samson Oladipo

DevOps enthusiast sharing real-world insights. ๐Ÿš€ #Automation #CI/CD #InfrastructureAsCode