today I want to write a few words about Dockerfile.
So, as usually for developer it will not be enough just ordinary docker images. Quite often they need to add some more features to docker images. One of the useful ways to organize it can be creating Dockerfile.
Dockerfile in itself just a text file with instructions. Of course that instructions are docker specific. And it's similar to making program say in C#. While after C# program I need to execute compiler, with Dockerfile I need to execute command docker build. You can consider docker build as compiler from Docker.
Executed image is a container.
Dockerfile has build instructions.
Some docker instructions
FROM - points to basic image.
MAINTEINER - say who maintains image
RUN - with this command you can point either you need to download something from internet, compile source code, RUN npm install, etc
COPY - copy something into container
ENTRYPOINT - what is main entrypoint of your container. Something that starts container functionality. javatype, nodejs, dnx, etc types of commands
WORKDIR - configure context for where that container is executed
EXPOSE - expose port
ENV - define environment varialbes
VOLUME - define volume and how it is stored in host system
Some samples of instructions:
FROM node - means the following from node build an image, grab node, and add additional layers on top of it
MAINTAINER firstname.lastname@example.org - to whom write an email.
RUN npm install - execute npm install command
EXPOSE 8080 - open port 8080
COPY . /app - copy content of local folder into folder app
After you created your docker file, you can use docker build like tis
docker build -t somename/aspnetcore .
Take not that . in the end is named Build context. It shows where is Dockerfile.