How to create our own Docker Image

Create our own docker Image

-> Why would we need it in the 1st place, Because if you can’t find a command or service, which is not available in the Docker Hub

-> In the below example, We are using Python “flask” framework to containerize a simple python Web-application

Lets get started:

-> Create a Docker file in the format: [Instruction] [Argument]

How to create our own Docker Image

-> Build docker file

docker build -t webapp <docker image file path>
Sending build context to Docker daemon  121.3kB
Step 1/6 : FROM python:3.6
3.6: Pulling from library/python
0e29546d541c: Pull complete 
9b829c73b52b: Pull complete 
cb5b7ae36172: Pull complete 
6494e4811622: Pull complete 
6f9f74896dfa: Pull complete 
5e3b1213efc5: Pull complete 
9fddfdc56334: Pull complete 
404f02044bac: Pull complete 
c4f42be2be53: Pull complete 
-> Once the build is complete. You can able to list the image in the repo

docker images 

-> Once it is available, we can run the image using docker command

docker run -p 8181:8080 webapp

Now, You can able to access the webapp from the external port 8181 from the host

Click here for detailed explanation on creating Dockerfile

Please do share if have any questions or can give a quick chat to discuss on this

Similar Posts