I have been using Docker and Kubernetes for several years now but never really took any time to really read about it. There were a lot of gaps in my understanding of how Docker works and what really is possible with it. Just recently my employer started to offer Udemy’s subscription, so I took Hands on Docker course. Here are some of the important things I learned in this course.
Where do you run Docker containers
You run these in Windows or MacOS but most likely you will use Linux in production. And unlike Windows and MacOS, you can run Docker on Linux VPS.
Important Docker commands
# get running docker containers
docker ps
# get all docker containers including those that have exited
docker ps -a
# stop container by its id or name
docker stop first_few_chars_of_id
# list docker images stored on the host
docker images
# remove image
docker rmi image_name
# download a new image
docker pull image_name
docker pul image_name:specific_tag
# append a command
docker run image_name command to run with parameters
docker run ubuntu sleep 5# execute command in a conatiner
docker exec container_id cat /etc/hosts
# interactive session inside container
docker exec -it conatiner_id /bin/bash
# run container in background/daemon mode
docker run -d webapp
# tail logs
docker logs -f conatiner_id
# attach to conatiner running in detach/daemon mode
docker attach container_id
# map ports, for example, to map port 80 on host to port 8080 in container
dokcer run -p 80:8080 webapp
Everything seemed okay but email were not getting delivered. Logs showed me that smtp connections were timing out:
tail -f /var/log/mail.log
May 3 12:28:10 postfix/smtp[3160]: connect to gmail-smtp-in.l.google.com[172.217.197.27]:25: Connection timed out
May 3 12:28:10 postfix/smtp[3160]: connect to alt1.gmail-smtp-in.l.google.com[2800:3f0:4003:c00::1a]:25: Network is unreachable
May 3 12:28:40 postfix/smtp[3160]: 4984C41A1E: to=<xxxx@gmail.com>, relay=none, delay=3246, delays=3186/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:400b:c00::1a]:25: Network is unreachable)
However, I could ping any of above ip addresses just fine.
Next step was to see if ip address of my VPS was blacklisted in RBLs, I used https://mxtoolbox.com/blacklists.aspx. None of my ip addresses were in any black list.
Port 25 was open in firewall, both on server and in Lightsail’s networking UI.
Without full understanding, I had enabled HSTS on amerkhalid.com with option includeSubDomains. I had a subdomain that was used as “Custom Domain” to SmugMug site. After enabling HSTS, these subdomains started to throw NET::ERR_CERT_COMMON_NAME_INVALID.
The fix is of course simple, don’t use includeSubDomains. But that opens up your top level domain to man in middle attacks.
For now, I decided to follow the best practices and leave includeSubDomains enabled. And decided to not use custom domain for my SmugMug site.
> interactive-adventure-game-tool@1.0.0 start /Users/amer/alexa/interactive-adventure-game-tool
> node node_modules/gulp/bin/gulp.js
/Users/amer/alexa/interactive-adventure-game-tool/node_modules/require-dir/index.js:97
if (!require.extensions.hasOwnProperty(ext)) {
^
TypeError: require.extensions.hasOwnProperty is not a function
at requireDir (/Users/amer/alexa/interactive-adventure-game-tool/node_modules/require-dir/index.js:97:37)
at Object.<anonymous> (/Users/amer/alexa/interactive-adventure-game-tool/gulpfile.js:1:85)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Liftoff.handleArguments (/Users/amer/alexa/interactive-adventure-game-tool/node_modules/gulp/bin/gulp.js:116:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! interactive-adventure-game-tool@1.0.0 start: `node node_modules/gulp/bin/gulp.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the interactive-adventure-game-tool@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/amer/.npm/_logs/2018-01-02T05_12_24_832Z-debug.log