The instructor recommends that in day to day activities we should be using docker-compose YAML files instead of complex docker commands on terminal.
The first insight I had (as a DevOps Eng.), was to have a docker-compose setup for each job on a pipeline. Being able to quickly reproduce the pipeline locally.
-d
to detach)--build
to always build-v
to delete volumesbuild
just [re]build image(s)stop
just stop containers, don't deleteps
list "services"push
images to registrylogs
same as docker CLIexec
same as docker CLIclone the repo: https://github.com/BretFisher/docker-mastery-for-nodejs
# inside the repository directory...
# run through simple compose commands
cd sample-02
docker compose up
#
{ #c}
(same as `docker-compose stop`)
docker compose down
docker compose up -d # detached
docker compose ps
docker compose logs
# while app is running detached...
docker compose exec web sh
curl localhost # curl is not installed...
exit
# edit Dockerfile, add curl with apk
# RUN apk add --update curl
docker compose up -d # it won't rebuild the image
# force rebuild the image
docker compose up -d --build
# now try curl again
docker compose exec web sh
curl localhost # not it should works!
exit
# to finalize the assignment...
# inside sample-02/ dir
docker compose down