Day 17:Docker Project for DevOps Engineers.
Table of contents
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.
Task
Create a Dockerfile for a simple web application (e.g. a Node.js or Python app)
Dockerfile contains information to build images
Dockerfile instruction
FROM > Base Image
LABELS >Adds metadata to an image
RUN > Execute commands in a new layer and commit the results.
ADD/COPY > Add files and folder into the image
CMD > Run binaries /commands on docker run
ENTRYPOINT > Allows you to configure a container that will run as an executable
VOLUME> Creates a mount point and marks it as holding externally mounted volumes
EXPOSE> Containers listen on the specified network ports at runtime.
ENV > Sets the environment variable
USER > Set the user name or (UID)
WORKDIR > Sets the working dir
ARG > Defines a variable that the user can pass at build time
ONBUILD > Adds to the image a trigger instruction to be executed at a later time.
vim Dockerfile
[After creating a docker file clone https://github.com/LondheShubham153/react_django_demo_app.git
requirements file from above git link]
Build the image using the Dockerfile and run the container
Build an image from the docker file
docker build . -t todopython:app1
To run the container
docker run -p 8001:8001 todopython:app1
Verify that the application is working as expected by accessing it in a web browser
Push the image to a public or private repository (e.g. Docker Hub )docker tag
create a docker hub account
create a docker hub public repository
change local image tag according to the docker hub suggest
Docker tag todopython dwarika9167/todoapp:app1
Docker login
docker login #provide username & password
Push the image to a public or private repository docker push
docker push dwarika9167/todoapp:app1
Thank you for reading the blog completed #day17
Subscribe to my newsletter
Read articles from Dhwarika Jha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by