Working with Dockerfile
Dockerfile is a file used to build images by reading instructions from a file. The default name is used as Dockerfile
. You can create dockerfile in the current directory with specific instructions and build a customized image as per your requirements.
Build Image with Dockerfile
As a best practice, the Dockerfile is called Dockerfile and is located in the root of the context. You can use the following command to build a docker image. This will read Dockerfile in the current directory.
You can also use the -f flag with the docker build command to point to a Dockerfile anywhere in your file system.
Create a Dockerfile
For this tutorial, I have created a sample project on Github. Just clone the repository using the following command.
Now build the docker image with the name apache image.
After the build, You can view the image under the “docker images” command.
Launch Container with Image
Now the time is for creating the instance using the latest image created.
The above command will launch a docker container using the image apache image. Here I have bound host system port 8080 with container port 80, so you can access the Apache running on a container.
0 Comments
CAN FEEDBACK
Emoji