<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adriano Galello</title>
    <description>The latest articles on DEV Community by Adriano Galello (@gdi3d).</description>
    <link>https://dev.to/gdi3d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F357896%2Faa0e4a9e-93e5-4963-8196-66ffbb2eb9f0.jpeg</url>
      <title>DEV Community: Adriano Galello</title>
      <link>https://dev.to/gdi3d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gdi3d"/>
    <language>en</language>
    <item>
      <title>Curso ABC.Docker</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Wed, 27 Dec 2023 09:54:01 +0000</pubDate>
      <link>https://dev.to/gdi3d/curso-abcdocker-4e33</link>
      <guid>https://dev.to/gdi3d/curso-abcdocker-4e33</guid>
      <description>&lt;p&gt;Curso introductorio a Docker. Diseñado para todas las personas que tengan un conocimiento básico de desarrollo y quieran comenzar a utilizar Docker.&lt;br&gt;
Obtendrás los conocimientos necesarios para comenzar a utilizarlo en tu día a día.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/abcdocker/docs/#/"&gt;https://gdi3d.github.io/abcdocker/docs/#/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>español</category>
      <category>newbie</category>
      <category>devops</category>
      <category>programming</category>
    </item>
    <item>
      <title>Build Safer Docker Images</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Tue, 20 Jun 2023 06:25:14 +0000</pubDate>
      <link>https://dev.to/gdi3d/build-safer-docker-images-ka9</link>
      <guid>https://dev.to/gdi3d/build-safer-docker-images-ka9</guid>
      <description>&lt;p&gt;When you're building your container image there are at least two effortless practices that you can follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prefer minimal base images&lt;/li&gt;
&lt;li&gt;Run process with Least privileged user&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prefer minimal base images
&lt;/h2&gt;

&lt;p&gt;Base images not only help speed up your CI/CD pipelines, reduce storage space and network traffic. They also help you reduce the attack surface of your container.&lt;/p&gt;

&lt;p&gt;Your container &lt;strong&gt;should only have the dependencies that it needs&lt;/strong&gt; to run and nothing more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I know, we all love to ssh into the container and use vim, ping, or some other tool to debug it. But being lazy can get us into trouble very quickly 😊.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Explore the following base image options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://hub.docker.com/_/scratch/"&gt;Scratch&lt;/a&gt; If you are going to run a binary that doesn't need any other libs (GO programs for example).&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hub.docker.com/_/alpine/"&gt;Alpine&lt;/a&gt; The image is only 5 MB in size and has access to a package repository to install what you need.&lt;/li&gt;
&lt;li&gt;If you want/need more, you can also try images with &lt;em&gt;-slim&lt;/em&gt; version or even with &lt;em&gt;-alpine&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Run process with Least Privileged User
&lt;/h2&gt;

&lt;p&gt;Your process inside the container shouldn't run as root unless is mandatory.&lt;/p&gt;

&lt;p&gt;Having a process running as root means that an attacker could gain root access and perform an attack on the host.&lt;/p&gt;

&lt;p&gt;Imagine that someone mounts a volume to the container and an attacker was able to gain access to the container by the process running as root. They would be able to manipulate that external volume with no issues at all.&lt;/p&gt;

&lt;p&gt;What if that container has been launched using &lt;code&gt;--privileged&lt;/code&gt; flag?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The --privileged flag gives all capabilities to the container. When the operator executes docker run --privileged, Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host. Additional information about running with --privileged is available on the Docker Blog.&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities"&gt;https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As you can see, potential issues begin to emerge very quickly.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you run a process as non-root?
&lt;/h3&gt;

&lt;p&gt;In your &lt;code&gt;Dockerfile&lt;/code&gt; make sure you create a new regular user and then activate it.&lt;/p&gt;

&lt;p&gt;Here's an example of how it can be done&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
# crate a non-root user
ENV NONROOT_USER myappser
ENV NONROOT_UID 1000
ENV HOME /app

RUN adduser --disabled-password \
    --gecos "Default user" \
    --uid ${NONROOT_UID} \
    ${NONROOT_USER}

USER root
# all files in the home folder will
# be owned by the non-root user
RUN chown -R ${NONROOT_USER}:${NONROOT_USER} ${HOME}
USER ${NONROOT_USER}

# You can add your CMD after this if you want to
...

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Photo credit: &lt;a href="https://www.pexels.com/@francesco-ungaro/"&gt;Francesco Ungaro&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>security</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Every Day Docker Commands You Need To Learn</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Tue, 10 Jan 2023 08:43:35 +0000</pubDate>
      <link>https://dev.to/gdi3d/every-day-docker-commands-you-need-to-learn-3n1</link>
      <guid>https://dev.to/gdi3d/every-day-docker-commands-you-need-to-learn-3n1</guid>
      <description>&lt;h2&gt;
  
  
  Interacting with containers
&lt;/h2&gt;

&lt;p&gt;How to list all your running containers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to list all running and stopped containers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to run a command inside a container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec CONTAINER_NAME_OR_ID command
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Cool tip: You can use the first 4 characters of the container id instead of the full name or full id. It works with all commands 😎&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;How to access a Linux container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it CONTAINER_NAME_OR_ID bash

# in case of no bash, like alpine versions for ex., you can try
docker exec -it CONTAINER_NAME_OR_ID sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to display logs live&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs -f CONTAINER_NAME_OR_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to launch and run a container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run CONTAINER_NAME:TAG

# use -d and will be launched in the background
docker run -d nginx:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to stop a container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop CONTAINER_NAME_OR_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to restart a container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker restart CONTAINER_NAME_OR_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Managament Commands
&lt;/h2&gt;

&lt;p&gt;How to list all images&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to delete an image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rmi IMAGE_NAME:TAG

# or
docker image rm IMAGE_NAME:TAG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to delete all images&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rmi -f $(docker images -qa)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to remove all stopped containers (-f to force it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker container prune -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to remove all unused local volumes (-f to force it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume prune -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to remove all unused networks (-f to force it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network prune -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to remove unused images (-f to force it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image prune -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to stop all containers (-f to force it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop -f $(docker ps -qa)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to delete all running and stopped containers (-f to force it)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rm -f $(docker ps -qa)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clean up your environment by running multiple commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop -f $(docker ps -qa) &amp;amp;&amp;amp; docker container prune -f &amp;amp;&amp;amp; docker volume prune -f &amp;amp;&amp;amp; docker image prune -f &amp;amp;&amp;amp; docker network prune -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extras
&lt;/h2&gt;

&lt;p&gt;How to build a docker image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t IMAGE_NAME:TAG location/to/Dockerfile

# Ex.: Running the command inside the of directory the Dockerfile
docker build -t mydockerimg:3.11 .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to display all containers stats (% CPU, Mem, I/O, PIDS..)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stats
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Image credit: &lt;a href="https://www.pexels.com/@dana-tentis-118658/" rel="noopener noreferrer"&gt;https://www.pexels.com/@dana-tentis-118658/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Become a FullStack DEV</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Sat, 07 Jan 2023 15:51:45 +0000</pubDate>
      <link>https://dev.to/gdi3d/become-a-fullstack-dev-3kej</link>
      <guid>https://dev.to/gdi3d/become-a-fullstack-dev-3kej</guid>
      <description>&lt;p&gt;Are you trying to become a fullstack dev?&lt;/p&gt;

&lt;p&gt;I've created a step by step tutorial to build your own web app from scratch using python, javascript, docker and more!&lt;/p&gt;

&lt;p&gt;It's not a TO-DO app, it's something real, with real problems and using multiple technologies to achieve it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/learning-to-build/" rel="noopener noreferrer"&gt;https://gdi3d.github.io/learning-to-build/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to contact me if you need support with it 😉&lt;/p&gt;

</description>
      <category>community</category>
      <category>discuss</category>
      <category>ai</category>
    </item>
    <item>
      <title>Creating Distributed Tasks using Python+Celery+Docker</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Thu, 25 Aug 2022 13:59:00 +0000</pubDate>
      <link>https://dev.to/gdi3d/distributed-task-pythoncelerydocker-3ie8</link>
      <guid>https://dev.to/gdi3d/distributed-task-pythoncelerydocker-3ie8</guid>
      <description>&lt;p&gt;I have written a small and fun project for anyone who wants to learn how to build webapps from the ground up.&lt;/p&gt;

&lt;p&gt;Today I want to share the infrastructure documentation about the project.&lt;/p&gt;

&lt;p&gt;With this project, you will learn how to build a webapp to convert YouTube videos to MP3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/learning-to-build/#/docker/architecture"&gt;https://gdi3d.github.io/learning-to-build/#/docker/architecture&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to use Python Celery+Docker to convert YT Videos to MP3</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Mon, 22 Aug 2022 07:13:18 +0000</pubDate>
      <link>https://dev.to/gdi3d/how-to-use-python-celerydocker-to-convert-yt-videos-to-mp3-1ffb</link>
      <guid>https://dev.to/gdi3d/how-to-use-python-celerydocker-to-convert-yt-videos-to-mp3-1ffb</guid>
      <description>&lt;p&gt;This project was created as a tutorial for people that are trying to improve their coding skills.&lt;/p&gt;

&lt;p&gt;You can check the full documentation to learn more, or just read this section&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/learning-to-build/#/app/converting-youtube-video-to-mp3-celery"&gt;https://gdi3d.github.io/learning-to-build/#/app/converting-youtube-video-to-mp3-celery&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;And then build your own.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Your Own YouTube to MP3 Web App (Tutorial)</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Mon, 08 Aug 2022 11:20:00 +0000</pubDate>
      <link>https://dev.to/gdi3d/your-own-youtube-to-mp3-web-app-tutorial-c9p</link>
      <guid>https://dev.to/gdi3d/your-own-youtube-to-mp3-web-app-tutorial-c9p</guid>
      <description>&lt;p&gt;This project was created as a tutorial for people that are trying to improve their coding skills.&lt;/p&gt;

&lt;p&gt;To-Do apps are ok for a quick look, but the best way to learn is by trying to do something a little bit complex and being able to change parts of the code and see what happens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/learning-to-build"&gt;https://gdi3d.github.io/learning-to-build&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>python</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Mac Battery Fully Charged Notification</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Sat, 16 Jul 2022 16:15:43 +0000</pubDate>
      <link>https://dev.to/gdi3d/mac-battery-fully-charged-notification-579b</link>
      <guid>https://dev.to/gdi3d/mac-battery-fully-charged-notification-579b</guid>
      <description>&lt;p&gt;I kept on forgetting my mac was charging and most of the time the battery would be at 100% for a few hours before I realize it. &lt;/p&gt;

&lt;p&gt;So created a small script that will notify you when your mac is fully charged.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/osx-mac-notify-battery-fully-charge/"&gt;https://gdi3d.github.io/osx-mac-notify-battery-fully-charge/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sideprojects</category>
      <category>bash</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Google Authenticator does not backup up your keys in your Google account</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Mon, 03 Jan 2022 15:01:28 +0000</pubDate>
      <link>https://dev.to/gdi3d/google-authenticator-does-not-backup-up-your-keys-in-your-google-account-2ami</link>
      <guid>https://dev.to/gdi3d/google-authenticator-does-not-backup-up-your-keys-in-your-google-account-2ami</guid>
      <description>&lt;p&gt;On Sunday noon I decided to install &lt;a href="https://lineageos.org/"&gt;Lineage OS&lt;/a&gt; on my phone.&lt;/p&gt;

&lt;p&gt;I knew I had everything backed up and the only thing I was worried about was Google Authenticator App. Then I remember that when I installed the app, google gave me recovery codes that I had safely stored away.&lt;/p&gt;

&lt;p&gt;After an hour the whole installation was over and it was time to restore my apps and settings in the new OS.&lt;/p&gt;

&lt;p&gt;Once the Google Authenticator app was installed I opened the app and notice it was empty. That's ok, I thought, pretty sure I've to enter some of those codes to recovery my keys.&lt;/p&gt;

&lt;p&gt;But I didn't see any options to do that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=pl5gIYq3PUo"&gt;https://www.youtube.com/watch?v=pl5gIYq3PUo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Play me for dramatic effect&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It turns out that &lt;strong&gt;Google Authenticator does not save your accounts in your Google Account&lt;/strong&gt;. They exist only on your phone. (You can search about this if you don't trust me)&lt;/p&gt;

&lt;p&gt;After having 5 heart attacks in a row, I started to think: Well... how many accounts did I had set up in there?? and for what sites? and what happened to those codes, what were they for?.&lt;/p&gt;

&lt;p&gt;And so it began the task to recover my 8 2FA secured accounts without the 2FA tokens available. Oh, and those codes were just for recovering the Google account and nothing else (big mistake on my part).&lt;/p&gt;

&lt;p&gt;Luckily I had a lot of them open on my computer and was able to quickly disable and re-enable to add them back again on the Google Authenticator app.&lt;/p&gt;

&lt;p&gt;Some websites know that stupid people like me do stupid things and give you a way to disable your 2FA, with a code that they provide when you enable the 2FA, or offer a recovery mode sending an SMS to your phone.&lt;/p&gt;

&lt;p&gt;But others just give you the finger and you get locked out.&lt;/p&gt;

&lt;p&gt;One of those sites, not going to disclose which one, didn't offer me any alternative method like sending an SMS when you don't have the 2FA token. And this site was &lt;strong&gt;EXTREMELY IMPORTANT&lt;/strong&gt; to me.&lt;/p&gt;

&lt;p&gt;After panicking a little more I started to look at how to solve it. &lt;/p&gt;

&lt;p&gt;I searched for any hacks, tricks, or anything to do, but didn't find anything. So I decided to try the support number.&lt;/p&gt;

&lt;p&gt;No one answered.... I waited for about an hour or so and called again. This time someone did answer and after a 15 minutes call, they were able to set the SMS method as the primary one. Luckily I had that enabled and set up before when I enabled the 2FA.&lt;/p&gt;

&lt;p&gt;This whole mess started at around 13:00 and ended at 18:30.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to backup your Google Authenticator then?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;There's no tool or option to do it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The only thing you can do is use &lt;a href="https://www.wikihow.com/Transfer-Authenticator-Codes-to-New-Phone"&gt;the option to export your keys to another device&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This will show you a QR that you can scan with your new device to transfer the accounts. But you can't screenshot it, save it, or anything like that (for security reasons).&lt;/p&gt;

&lt;p&gt;My solution is to start looking for a new MFA App, there aren't many out there and most of them use their cloud to store your keys.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fun Fact: If I had searched 'How to backup google authenticator' I would have found out all of this on my first click 🥲&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>A Tiny Microservices for Emails and Calendar Invitations</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Tue, 23 Nov 2021 15:05:29 +0000</pubDate>
      <link>https://dev.to/gdi3d/calenvite-1dap</link>
      <guid>https://dev.to/gdi3d/calenvite-1dap</guid>
      <description>&lt;p&gt;I've created a tiny Microservice in Go that can be used by anyone building an app with the need of sending emails and calendar invitations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gdi3d.github.io/calenvite/"&gt;https://gdi3d.github.io/calenvite/&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;A simple microservice designed in &lt;a href="https://golang.org/"&gt;GO&lt;/a&gt; using &lt;a href="https://echo.labstack.com/"&gt;Echo Microframework&lt;/a&gt; for sending emails and/or calendar invitations to users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Send emails using your Mailgun API credentials.&lt;/li&gt;
&lt;li&gt;Send using a standar SMTP server.&lt;/li&gt;
&lt;li&gt;Support for HTML and Plain Text emails.&lt;/li&gt;
&lt;li&gt;Calendar invitation with RSVP.&lt;/li&gt;
&lt;li&gt;Docker image is built using multistage and alpine image to keep it as small and secure as possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Use
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Build the Docker image
&lt;/h3&gt;

&lt;p&gt;Download the repo and build the docker image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ git clone https://github.com/gdi3d/calenvite
  $ docker build -t calenvite_svc:latest .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and use provided docker-compose files for more info.&lt;/p&gt;

&lt;h3&gt;
  
  
  Or Build the binary
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/gdi3d/calenvite
$ go get -d -v
$ go mod download
$ go mod verify
$ go build -a -o calenvite

# run de service
$ ./calenvite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Set the Env vars
&lt;/h3&gt;

&lt;p&gt;There's a few env vars that you need to set when you launch the container in order to work:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# If you want use Mailgun API:
CALENVITE_SVC_MAILGUN_DOMAIN: The domain from which the email are going to be sent
CALENVITE_SVC_MAILGUN_KEY: The Mailgun API secret key

# If you want to use SMTP:
CALENVITE_SVC_SMTP_HOST: The host/ip of the SMTP server
CALENVITE_SVC_SMTP_PORT: The port of the SMTP server
CALENVITE_SVC_SMTP_USER: The username to authenticate to the SMTP server
CALENVITE_SVC_SMTP_PASSWORD: The password to authenticate to the SMTP server

# common to both options
CALENVITE_SVC_EMAIL_SENDER_ADDRESS: The email address that would be used to send the email (this value will be used in the FROM part of the email)
CALENVITE_SVC_SEND_USING: MAILGUN or SMTP
CALENVITE_SVC_PORT: Port to expose (optional, default: 8000)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sample docker-compose files included
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# mailgun-docker-compose.yml

version: "3.9"
services:
  app_backend:
    image: calenvite_svc:latest
    ports:
      - "8080:8000"
    environment:
      - CALENVITE_SVC_MAILGUN_DOMAIN=mycooldomain.com
      - CALENVITE_SVC_MAILGUN_KEY=abcd1234
      - CALENVITE_SVC_EMAIL_SENDER_ADDRESS=no-reply@mycooldomain.com
      - CALENVITE_SVC_SEND_USING=MAILGUN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# smtp-docker-compose.yml

version: "3.9"
services:
  app_backend:
    image: calenvite_svc:latest
    ports:
      - "8080:8000"
    environment:
      - CALENVITE_SVC_SMTP_HOST=smtp.mailprovider.com
      - CALENVITE_SVC_SMTP_PORT=587
      - CALENVITE_SVC_SMTP_USER=mysmtpuser
      - CALENVITE_SVC_SMTP_PASSWORD=shhhh.is.secret
      - CALENVITE_SVC_EMAIL_SENDER_ADDRESS=no-reply@mycooldomain.com
      - CALENVITE_SVC_SEND_USING=SMTP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API Docs
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Healtcheck Endpoint
&lt;/h2&gt;

&lt;p&gt;A healthcheck endpoint to test if the service is up and running and a valid configuration is present.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This healtcheck is only going to check that the environment vars are defined. It will not check if the credentials are valid or not&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  URL
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;/healthcheck/&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Request Example
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;curl --location --request GET 'http://127.0.0.1:8080/healthcheck'&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Responses
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Service ok&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 
Content-Type: application/json; charset=UTF-8
Vary: Accept-Encoding

null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Service not working&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 500 Internal Server Error 
Content-Type: application/json; charset=UTF-8
Vary: Accept-Encoding

{
    "message": "Internal Server Error"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Invite Endpoint
&lt;/h2&gt;

&lt;p&gt;Send email, and optionally, an calendar invitation with RSVP to the users.&lt;/p&gt;

&lt;h3&gt;
  
  
  URL
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;/invite/&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Payload
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "users": [
        {
            "full_name": "Eric Cartman",
            "email": "ihateyouguys@southpark.cc"
        },
        {
            "full_name": "Tina belcher",
            "email": "aaaooo@bobsburger.com"
        }
    ],
    "invitation": {
        "start_at": "2030-10-12T07:20:50.52Z",
        "end_at": "2030-10-12T08:20:50.52Z",
        "organizer_email": "meetingorganizer@meeting.com",
        "organizer_full_name": "Mr. Mojo Rising",
        "summary": "This meeting will be about...",
        "location": "https://zoom.us/332324342",
        "description": "Voluptatum ut quis ut. Voluptas qui pariatur quo. Omnis enim rerum dolorum. Qui aut est sed qui voluptatem harum. Consequuntur et accusantium culpa est fuga molestiae in ut. Numquam harum"
    },
    "email_subject": "You've just been invited!",
    "email_body": "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;email body about the invitation/event&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;",
    "email_is_html": true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Notes about fields:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you don't need to send a calendar invitation you can omit the field &lt;code&gt;invitation&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If you want to send plain text messages set the key &lt;code&gt;email_is_html&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Request example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl --location --request POST 'http://127.0.0.1:8080/invite/' \
--header 'Content-Type: application/json' \
--data-raw '{"users":[{"full_name":"Eric Cartman","email":"ihateyouguys@southpark.cc"},{"full_name":"Tina belcher","email":"aaaooo@bobsburger.com"}],"invitation":{"start_at":"2030-10-12T07:20:50.52Z","end_at":"2030-10-12T08:20:50.52Z","organizer_email":"meetingorganizer@meeting.com","organizer_full_name":"Mr. Mojo Rising","summary":"This meeting will be about...","location":"https://zoom.us/332324342","description":"Voluptatum ut quis ut. Voluptas qui pariatur quo. Omnis enim rerum dolorum. Qui aut est sed qui voluptatem harum. Consequuntur et accusantium culpa est fuga molestiae in ut. Numquam harum"},"email_subject":"You'\''ve just been invited!","email_body":"&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;email body about the invitation/event&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;","email_is_html":true}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Responses
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Successful&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 
Content-Type: application/json; charset=UTF-8
Vary: Accept-Encoding

{
    "message": "SENT_OK",
    "status_code": 200,
    "error_fields": null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Field missing/invalid&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 400 BAD REQUEST
Content-Type: application/json; charset=UTF-8
Vary: Accept-Encoding

{
    "message": "INVALID_PAYLOAD",
    "status_code": 400,
    "error_fields": [
        {
            "field": "email_body",
            "message": "",
            "code": "required"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Error&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=UTF-8
Vary: Accept-Encoding

{
    "message": "ERROR",
    "status_code": 500,
    "error_fields": null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Questions, complains, death threats?
&lt;/h2&gt;

&lt;p&gt;You can &lt;a href="https://www.linkedin.com/in/adrianogalello/"&gt;Contact me 🙋🏻‍♂️&lt;/a&gt; on LinkedIn if you have any questions. Otherwise you can open a ticket 😉&lt;/p&gt;

</description>
      <category>go</category>
      <category>microservices</category>
      <category>docker</category>
      <category>sideprojects</category>
    </item>
    <item>
      <title>Docker environment variables naming</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Mon, 02 Aug 2021 09:16:12 +0000</pubDate>
      <link>https://dev.to/gdi3d/docker-environment-variables-naming-5dh8</link>
      <guid>https://dev.to/gdi3d/docker-environment-variables-naming-5dh8</guid>
      <description>&lt;p&gt;When you start to build an application you will definitively want to use environment variables for sensitive values like passwords, or configurations.&lt;/p&gt;

&lt;p&gt;These values should never be hardcoded since it's a security issue. It will also help you make your application easier to maintain.&lt;/p&gt;

&lt;p&gt;Typically you will also have one configuration file per environment: &lt;br&gt;
Development, Preproduction, and Production.&lt;/p&gt;

&lt;p&gt;Take a look at the following docker-compose for our next unicorn app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3.9"
services:
  app_backend:
    image: killerapp:latest
    ports:
      - "8080:8000"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_SCHEMA=${DB_SCHEMA}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks about right, and you're probably familiar with this kind of configuration. But this presents a problem that could be potentially dangerous.&lt;/p&gt;

&lt;p&gt;There's a chance that someone accidentally set the env vars for one environment into another one.&lt;/p&gt;

&lt;p&gt;Imagine what can happen if you end up using the production values in your preproduction or development environment.&lt;/p&gt;

&lt;p&gt;One best practice is to have different variables for your environments.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;There are other ways to prevent these issues like having your environments in different servers, VPC's, accounts, etc.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In our example, the docker-compose.yml will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3.9"
services:
  app_backend:
    image: killerapp:latest
    ports:
      - "8080:8000"
    environment:
      - DEV_DB_HOST=${DEV_DB_HOST}
      - DEV_DB_USER=${DEV_DB_USER}
      - DEV_DB_PASSWORD=${DEV_DB_PASSWORD}
      - DEV_DB_SCHEMA=${DEV_DB_SCHEMA}
      - PRE_DB_HOST=${PRE_DB_HOST}
      - PRE_DB_USER=${PRE_DB_USER}
      - PRE_DB_PASSWORD=${PRE_DB_PASSWORD}
      - PRE_DB_SCHEMA=${PRE_DB_SCHEMA}
      - PRO_DB_HOST=${PRO_DB_HOST}
      - PRO_DB_USER=${PRO_DB_USER}
      - PRO_DB_PASSWORD=${PRO_DB_PASSWORD}
      - PRO_DB_SCHEMA=${PRO_DB_SCHEMA}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way is much harder for a developer/DevOps to accidentally use the production credentials in another environment.&lt;/p&gt;

&lt;p&gt;The takeaway is that if you should have an environment-sensitive variable naming approach to make them crystal clear. This way, anyone that it's not familiar with the app config will be less prone to make mistakes.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to connect docker containers</title>
      <dc:creator>Adriano Galello</dc:creator>
      <pubDate>Thu, 29 Jul 2021 08:20:59 +0000</pubDate>
      <link>https://dev.to/gdi3d/how-to-connect-docker-containers-4hai</link>
      <guid>https://dev.to/gdi3d/how-to-connect-docker-containers-4hai</guid>
      <description>&lt;p&gt;Did you know that you can use the service name of a container or id to connect to it on Docker?&lt;/p&gt;

&lt;p&gt;If you have used the &lt;code&gt;--link&lt;/code&gt; option when launching a container or docker compose, you can call the container by its name or id from other containers. But how does this work?&lt;/p&gt;

&lt;p&gt;The answer is simple: DNS.&lt;/p&gt;

&lt;p&gt;Whenever you launch a container, Docker provides a network for you and uses the DNS service provided by the Docker daemon.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can override the default docker network and DNS settings &lt;a href="https://docs.docker.com/network/" rel="noopener noreferrer"&gt;Check the docs here&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Scenario
&lt;/h1&gt;

&lt;p&gt;Let's assume that you have 3 tier application: Frontend, Backend, and a Database.&lt;/p&gt;

&lt;p&gt;Your backend needs to be able to connect to the database. The safest way to do so is to keep your database in a private network to connect to it.&lt;/p&gt;

&lt;p&gt;With docker you can use the &lt;strong&gt;service name&lt;/strong&gt; or &lt;strong&gt;container ID&lt;/strong&gt; as the server name in your configuration file.&lt;/p&gt;

&lt;p&gt;Ex.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cn = mysql.connect(user='produser',
                 password='secretvalue',
                 host='svc_database', # this is the service name in the incoming example
                 database='mysuperapp')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Launching a few containers
&lt;/h1&gt;

&lt;p&gt;Clone the following repository using the command below:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone git@github.com:gdi3d/docker-dns.git .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now take a look at the file &lt;code&gt;docker-compose.yml&lt;/code&gt; in the repository you just cloned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3.9"  # optional since v1.27.0
services:
  svc_frontend:
    image: busybox:latest
    command: top
  svc_database:
    image: busybox:latest
    command: top
  svc_backend:
    image: busybox:latest
    command: top
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see three services defined:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;svc_frontend&lt;/strong&gt;: App frontend&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;svc_database&lt;/strong&gt;: App database&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;svc_backend&lt;/strong&gt;: App backend&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;To make things easier we're using busybox image to simulate the services.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Launch the containers using &lt;code&gt;docker-compose up -d&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can check that the containers are running using &lt;code&gt;docker ps&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://asciinema.org/a/9c6y0KEEPnflskE9lHQk2dc9B" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fasciinema.org%2Fa%2F9c6y0KEEPnflskE9lHQk2dc9B.svg" alt="asciicast"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The Test
&lt;/h1&gt;

&lt;p&gt;We're going to test the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Where's the Docker DNS service running at (the ip address)&lt;/li&gt;
&lt;li&gt;Try to ping a container by its service name and ID.&lt;/li&gt;
&lt;li&gt;Are the requests being resolved by Docker DNS service?.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These are our containers with their service name and IDs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service Name&lt;/th&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;svc_frontend&lt;/td&gt;
&lt;td&gt;1ee9c76938ee&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;svc_database&lt;/td&gt;
&lt;td&gt;fe0228bd99a5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;svc_backend&lt;/td&gt;
&lt;td&gt;a96e0cb74351&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Where's the Docker DNS service at?
&lt;/h2&gt;

&lt;p&gt;Let's access &lt;strong&gt;svc_backend&lt;/strong&gt; container and type &lt;code&gt;cat /etc/resolv.conf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://asciinema.org/a/03SuxkQKPMkaaZkqcKB0H6acn" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fasciinema.org%2Fa%2F03SuxkQKPMkaaZkqcKB0H6acn.svg" alt="asciicast"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see that nameserver has been pointed to &lt;strong&gt;127.0.0.11&lt;/strong&gt;. That's the Docker DNS service provided by the Docker daemon.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro tip: You don't need to type the whole ID of the container to perform an operation, just use the first two or three characters &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Try to ping a container by it's service name and ID
&lt;/h2&gt;

&lt;p&gt;You can check the connectivity against the &lt;strong&gt;svc_database&lt;/strong&gt; using the ping command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://asciinema.org/a/YySX7WKFu9DAemMitcvNVaAvY" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fasciinema.org%2Fa%2FYySX7WKFu9DAemMitcvNVaAvY.svg" alt="asciicast"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, we obtain the same response when calling it by its service name &lt;strong&gt;svc_database&lt;/strong&gt; or docker id &lt;strong&gt;fe0228bd99a5&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They both resolve to the same IP &lt;strong&gt;172.19.0.3&lt;/strong&gt; as expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are the requests being resolved by Docker DNS service?
&lt;/h2&gt;

&lt;p&gt;Let's use &lt;a href="https://linux.die.net/man/1/nslookup" rel="noopener noreferrer"&gt;nslookup&lt;/a&gt; to have a detailed report on what's going on when we try to call a container by its service name or ID.&lt;/p&gt;

&lt;p&gt;Running these two commands will give us a better understanding of what's going on: &lt;code&gt;nslookup svc_database&lt;/code&gt; and &lt;code&gt;nslookup fe0228bd99a5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://asciinema.org/a/MwskW7pRgr14uwQKuD8I1r5Ll" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fasciinema.org%2Fa%2FMwskW7pRgr14uwQKuD8I1r5Ll.svg" alt="asciicast"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server:     127.0.0.11
Address:    127.0.0.11:53

Non-authoritative answer:
Name:   svc_database
Address: 172.23.0.2

--------------------------

Server:     127.0.0.11
Address:    127.0.0.11:53

Non-authoritative answer:
Name:   fe0228bd99a5
Address: 172.19.0.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the results of nslookups we can see that the request is made using the docker DNS service at 127.0.0.11 and that, again, using the service name &lt;strong&gt;svc_database&lt;/strong&gt; or the container id &lt;strong&gt;fe0228bd99a5&lt;/strong&gt; the destination is the same ip &lt;strong&gt;172.19.0.3&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Further Reading
&lt;/h1&gt;

&lt;p&gt;If you want to know more about how the docker networking works you can check the &lt;a href="https://docs.docker.com/network/" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>codenewbie</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
