# Day 17 Task: Docker Project for DevOps Engineers

### Dockerfile

Docker is a tool that makes it easy to run applications in containers. Containers are like small packages that hold everything an application needs to run. To create these containers, developers use something called a Dockerfile.

A Dockerfile is like a set of instructions for making a container. It tells Docker what base image to use, what commands to run, and what files to include. For example, if you were making a container for a website, the Dockerfile might tell Docker to use an official web server image, copy the files for your website into the container, and start the web server when the container starts

1. **Create a Dockerfile:** Create a file named `Dockerfile` in your project directory with the following content:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701198453552/92badaa3-30b4-4667-9ade-9b8257ef5eda.png align="center")
    
    Make sure to adjust the above file based on your actual application structure and dependencies.
    
2. **Build the Docker Image:** Open a terminal, navigate to the directory containing the Dockerfile, and run the following command:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701198750296/c4ef7eb2-0c8e-43d8-adef-fcef03c97d26.png align="center")
    
3. **Run the Docker Container:** Once the image is built, you can run the container using the following command:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701199011618/f0c73bbe-4430-434a-8bf0-f3410a26ca9f.png align="center")
    
    1. This command maps port 3000 on your host machine to port 3000 on the Docker container.
        
    2. **Verify the Application:** Open a web browser and navigate to [`http://localhost:3000`](http://localhost:3000) to check if your web application is working as expected.
        
    3. **Push the Image to Docker Hub:** Before pushing the image to Docker Hub, you need to log in to your Docker Hub account using the following command:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701199441840/8a791a57-86dd-4de5-a387-7d01695fc151.png align="center")
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701199464154/3683a2b3-3300-4c5f-98d1-f614760ad0ed.png align="center")
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701199567204/80ab2594-f3fc-4132-b306-b06c85eaea53.png align="center")
