Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 1.88 KB

dockerfiles.md

File metadata and controls

74 lines (50 loc) · 1.88 KB

for simple docker file basics [click me..]

build docker image from docker file

docker build -t image_name -f dir/to/docker_file

use of tags xyz

docker build -t image_name:xyz -f dir/to/docker_file

the best way to run a docker container is with --init as it will create a proxy to the server so that ctrl+c can kill the process.

docker run --init docker-image-name

also if you are just playing with docker always use --rm

docker run --init --rm docker-image-name

use --publish outer_port:inner_port instead of EXPOSE

docker run --init --rm --publish 3000:3000 --name my-container my-image-name

-p is the shorthand for --publish

see example this [click me..]

multi-stage docker file

use From base_image_name as stage_name in dockerfile say the stage name is first_stage

From base_image_name as stage_name

in the satage where you want to copy something from fist_stage use

COPY --from:stage_name --chown=user_group:username /stage_contant_dir /destination_dir

for more see here.. [click me...]

see the Multistage build of a flask app


.dockerignore file

put all the files and folders in the .dockerignore file to not to copy it in the image

see example [click here]


important: volumes and mounts

Notes and example link : [click me]


docker-network

Notes and example link : [click me..]


docker-compose

Notes and example link : [click me]