Low Orbit Flux Logo 2 F

Docker How To Build An Image From Dockerfile

Building an image from a dockerfile is easy. We are going to show you how to get started today.


mkdir my-build              # create build dir
cd my-build                 # cd into build dir
vi Dockerfile               # edit build instructions
docker build -t my-imge .   # build the image
docker images               # show images
docker run my-image         # run the new image

Here is an real example that creates an NGINX web server based on the Ubuntu image:

This is an example Dockerfile that will create an image based on the Ubuntu image. Our version will have Nginx installed and running.


FROM ubuntu
RUN apt update
RUN apt install nginx -y
CMD ["/usr/sbin/nginx"]

For more details, check out our Docker Tutorial.