0% found this document useful (0 votes)
8 views2 pages

Docker - File

This document provides a comprehensive overview of Dockerfile instructions, including how to build images, set working directories, copy files, run commands, expose ports, and define default commands. It explains various commands such as FROM, WORKDIR, COPY, RUN, EXPOSE, CMD, ENTRYPOINT, ENV, and LABEL, detailing their syntax and usage. Additionally, it highlights the importance of .dockerignore for excluding files during the build process.

Uploaded by

adhamayad000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Docker - File

This document provides a comprehensive overview of Dockerfile instructions, including how to build images, set working directories, copy files, run commands, expose ports, and define default commands. It explains various commands such as FROM, WORKDIR, COPY, RUN, EXPOSE, CMD, ENTRYPOINT, ENV, and LABEL, detailing their syntax and usage. Additionally, it highlights the importance of .dockerignore for excluding files during the build process.

Uploaded by

adhamayad000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# comment Dockerfile

docker build -t adham00/image-name:v1.0 .

-t → tage of image
-f /path/to/dockerfile → add path

path of dockerfile →
. → in same dir
link GitHub → get docker file from github

.dockerignore → ignor coping files

***********************************************************************
1 - FROM

FROM Image-name → using this image or pull it first and use it

FROM python
FROM ubuntu:2.2
FROM adham00/image-name:v1.0
FROM python@Digist-of-image
FROM scratch → from Zero

***********************************************************************
2 - WORKDIR

WORKDIR /folder → change dir and if not exist make it and change the dir to it

***********************************************************************
3 - COPY , ADD

COPY file.txt . → copy this file from the same dir of the dockerfile (build
context) into the current dir into image
COPY file.txt /app/file.txt
COPY file1.txt file2.txt /app/ → tothis folder
COPY . /app/ → copy all from context to the /app/ DIR
COPY ["file name that we will copy" , "/app/"] → if the name of file have spaces
COPY ./src ./src → copy all content from folder src in context to ./src in image

ADD <URL> /app → same copy but use it to use file that dont inour context
ADD <tar> /app

***********************************************************************
4 - RUN , SHELL

SHELL ["/bin/bash" , "-c"] → select the bash that will RUN command in Dockerfile
will use to run commands
SHELL []

RUN pip install -r file.txt → run this command into the image (pip install -r
file.txt) when building image from dockerfile
RUN ["pip" , "install" , "-r" , "file.txt"] → Best Usage

***********************************************************************
5 - EXPOSE

metadata ::
EXPOSE 5000 → in a Dockerfile informs Docker that the container will listen on port
5000, allowing other containers to communicate with it, but it does not publish the
port to the host system. (work at run time) :: metaData of Image

***********************************************************************
6 - CMD , ENTRYPOINT

we use CMD → when user when run container from image dont add command in docker run
will use this command
we use ENTRYPOINT → when we want this command run

CMD dotnet backend.dll → this run this command when we make a container from this
image (defult command) run on (run time) on container :: metaData of Image

ENTRYPOINT ["dotnet" , "backend.dll"] → defult command canot be changed when we use


docker container run , CMD can change when run container using docker run

***********************************************************************
7 - ENV

metadata ::
ENV sql_user=sa pass_word="sasjs" → ‫بدل ما اكتبها فى ال االمر تشغيل الكونتينر‬

***********************************************************************

8 - LABLE

MetaData ::

LABEL developer="Adham Ayad"

You might also like