@@ -15,8 +15,8 @@ needs on any machine. You can get Docker for your machine from
1515[ docs.docker.com/get-docker/] ( https://docs.docker.com/get-docker/ )
1616
1717It has grown in popularity over the last decade due to being lightweight and
18- fast as compared to virtual-machines that are bulky and slow. Unlike VMs, docker
19- does not need a full blown OS of its own to be loaded to start and does not
18+ fast as compared to virtual-machines that are bulky and slow. Unlike VMs, Docker
19+ does not need a full- blown OS of its own to be loaded to start and does not
2020compete for resources other than what the application it is running will use.
2121VMs on the other hand are pretty resource intensive on our processors, disks and
2222memory hence running multiple VMs for various applications becomes a challenge
@@ -123,7 +123,7 @@ $ docker run -d ubuntu sleep 60s
123123# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
124124# 133261b4894a ubuntu "sleep 60s" 3 seconds ago Up 2 seconds vigorous_gould
125125
126- $ docker run < container-id > - p 3000:8000
126+ $ docker run - p 3000:8000 < image-id >
127127# The -p (or --publish) flag is used to expose port 8000 inside the container to
128128# port 3000 outside the container. This is because the app inside the container
129129# runs in isolation, hence the port 8000 where the app runs is private to the
@@ -133,9 +133,9 @@ $ docker run -i
133133# or
134134$ docker run -it
135135# Docker runs our containers in a non-interactive mode i.e. they do not accept
136- # inputs or work dynamically while running. The -i flag keeps input open to the
137- # container, and the -t flag creates a pseudo-terminal that the shell can attach
138- # to (can be combined as -it)
136+ # inputs or work dynamically while running. The -i (or --interactive) flag
137+ # keeps input open to the container, and the -t (or --tty) flag creates a
138+ # pseudo-terminal that the shell can attach to (can be combined as -it)
139139
140140$ docker ps -a
141141# The `docker ps` command only shows running containers by default. To see all
@@ -222,7 +222,8 @@ FROM <base-image>
222222
223223ENV USERNAME='admin' \
224224 PWD='****'
225- # optionally define environmental variables
225+ # optionally define environmental variables, real credentials
226+ # should be handled more securely (like using .env file)
226227
227228RUN apt-get update
228229# run linux commands inside container env, does not affect host env
@@ -244,15 +245,14 @@ CMD [<args>,...]
244245
245246### Build your images
246247Use the ` docker build ` command after wrapping your application into a Docker
247- image to run ( or build) it.
248+ image to run (or build) it.
248249
249250``` bash
250- $ docker build < path-to-dockerfile>
251- # used to build an image from the specified Dockerfile
252- # instead of path we could also specify a URL
253- # -t tag is optional and used to name and tag your images for e.g.
254- # `$ docker build -t my-image:0.1 ./home/app`
255- # rebuild images everytime you make changes in the dockerfile
251+ $ docker build -t < image-name> :< tag> < path-to-dockerfile>
252+ # used to build an image from the specified Dockerfile.
253+ # -t (or --tag) is used to give the image a name and tag.
254+ # Instead of path we could specify '.' (which means,
255+ # check for a Dockerfile in the current directory) or a URL.
256256```
257257
258258## Push your image to DockerHub
0 commit comments