What is a docker file How do I create a docker image with dockerfile

+1 vote
Jun 7, 2019 in Docker by Sam
• 6,260 points
4,550 views

1 answer to this question.

0 votes

 A Dockerfile is a script/text configuration file that contains collections of commands and instructions that will be automatically executed in sequence in the docker environment for building a new docker image.This file is written in a popular, human-readable Markup Language called YAML.

The docker build command processes this file generating a Docker Image in your Local Image Cache, which you can then start-up using the docker run command, or push to a permanent Image Repository.

We will create a new directory for the dockerfile and define what we want to do with that dockerfile.

  • Create a new directory and a new and empty dockerfile inside that directory.
mkdir dockerimages
cd dockerimages
touch dockerfile
  • Now Add a few docker commands in your docker file
From ubuntu

Maintainer "Siraj"

RUN apt-get update

RUN apt-get install vim -y

CMD /bin/echo "Hello! Welcome to docker Tutorial!!!"
  • Now the next step is to build the dockerfile to get the docker image.To do this, Run the following command, here "devopstrainer" is the tag name "ubuntu" is image name with a tag "dockerfile", inorder to understand that this image is created using a dockerfile:
docker build -t devopstrainer/ubuntu:dockerfile .
  • Your docker image would be successfully created. Verify this by running the command:
docker images
answered Jun 7, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

+1 vote
2 answers

How do I run a docker image as a container?

You can run an image depends on whether you ...READ MORE

answered Sep 7, 2018 in Docker by Damon Salvatore
• 5,980 points
1,623 views
0 votes
2 answers

How do I force Docker for a clean build of an image ?

You could try this inorder to clean ...READ MORE

answered Aug 6, 2019 in Docker by Sirajul
• 59,230 points
10,732 views
0 votes
1 answer

How do I start a Docker container with a volume?

You can first create the volume and ...READ MORE

answered Jul 2, 2019 in Docker by Namik
• 1,230 points
25,398 views
0 votes
1 answer

How do I delete the build cache for a docker image?

You could try this inorder to clean ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,230 points
12,669 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,738 views
0 votes
1 answer

how do I create an image from a tar archive in docker?

You can use docker load command inorder to get ...READ MORE

answered Jul 2, 2019 in Docker by Sirajul
• 59,230 points
8,705 views
+1 vote
2 answers

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 28, 2018 in Docker by Damon Salvatore
• 5,980 points
28,607 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP