<?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: Igor Souto</title>
    <description>The latest articles on DEV Community by Igor Souto (@soutoigor).</description>
    <link>https://dev.to/soutoigor</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%2F266622%2Fe4aaf83b-698d-4128-bebd-a0b3d4c8b6fa.jpeg</url>
      <title>DEV Community: Igor Souto</title>
      <link>https://dev.to/soutoigor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/soutoigor"/>
    <language>en</language>
    <item>
      <title>Docker machine: what is and the main commands</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Sun, 05 Jul 2020 00:09:22 +0000</pubDate>
      <link>https://dev.to/soutoigor/docker-machine-what-is-and-the-main-commands-581k</link>
      <guid>https://dev.to/soutoigor/docker-machine-what-is-and-the-main-commands-581k</guid>
      <description>&lt;p&gt;Docker machine allows us to easily deploy an environment from a local machine in any infrastructure service, like AWS, DigitalOcean, Google Cloud, etc, through the installation of the driver that you want, environment variables, etc.&lt;/p&gt;

&lt;p&gt;With that, we can create a host Docker in any of these platforms, and easily manage those machines from our local machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CREATE
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine create &lt;span class="nt"&gt;--driver&lt;/span&gt; virtualbox first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command, creates a new host docker, with the driver VirtualBox and with the name "first-host-box".&lt;/p&gt;

&lt;h3&gt;
  
  
  LS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists all the available hosts in your machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  ENV
&lt;/h3&gt;

&lt;p&gt;Lists the environment variables that need to be set.&lt;/p&gt;

&lt;p&gt;We can easily declare it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;docker-machine &lt;span class="nb"&gt;env &lt;/span&gt;first-host-box&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  IP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine ip first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists the ip of the host docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSH
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine ssh first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this command, we can access via SSH this host docker and use Linux commands inside it.&lt;/p&gt;

&lt;h3&gt;
  
  
  INSPECT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine inspect first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows details of the host docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  STOP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine stop first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stops the host.&lt;/p&gt;

&lt;h3&gt;
  
  
  START
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine start first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Starts the host.&lt;/p&gt;

&lt;h3&gt;
  
  
  RM
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine &lt;span class="nb"&gt;rm &lt;/span&gt;first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes the host.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With this, the Docker machine promotes great ease of installation and deployment in a cloud environment from its local containers.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockermachine</category>
      <category>infrastructure</category>
      <category>development</category>
    </item>
    <item>
      <title>Docker machine: o que é e principais comandos</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Sat, 04 Jul 2020 23:55:26 +0000</pubDate>
      <link>https://dev.to/soutoigor/docker-machine-lbi</link>
      <guid>https://dev.to/soutoigor/docker-machine-lbi</guid>
      <description>&lt;p&gt;A Docker machine possibilita deployar um ambiente de sua máquina local na infra que desejar, como AWS, DigitalOcean, Google Cloud etc, através da instalação do Driver que desejar, variáveis de ambiente e etc.&lt;/p&gt;

&lt;p&gt;Com isso estamos criando um host Docker em uma máquina de uma uma dessas plataformas, e podemos facilmente gerenciar essas máquinas de nossa máquina local.&lt;/p&gt;

&lt;h2&gt;
  
  
  Principais comandos
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CREATE
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine create &lt;span class="nt"&gt;--driver&lt;/span&gt; virtualbox first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Com este comando, estamos criando um novo "host Docker", com o driver VirtualBox e dando o nome de "first-host-box".&lt;/p&gt;

&lt;h3&gt;
  
  
  LS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Irá listar todos os hosts disponíveis em sua máquina.&lt;/p&gt;

&lt;h3&gt;
  
  
  ENV
&lt;/h3&gt;

&lt;p&gt;Irá listar todas as variáveis the ambiente que precisam ser configuradas.&lt;/p&gt;

&lt;p&gt;Nós podemos facilmente declarar com o seguinte comando:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;docker-machine &lt;span class="nb"&gt;env &lt;/span&gt;first-host-box&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  IP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine ip first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lista todos os IPs do nosso host Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSH
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine ssh first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Com este comando podemos facilmente acessar via SSH nosso host Docker e executar comandos Linux dentro dele.&lt;/p&gt;

&lt;h3&gt;
  
  
  INSPECT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine inspect first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mostra alguns detalhes do host Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  STOP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine stop first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Irá parar o host Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  START
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine start first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Irá iniciar o host Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  RM
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-machine &lt;span class="nb"&gt;rm &lt;/span&gt;first-host-box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove o host Docker.&lt;/p&gt;

&lt;p&gt;Com isso, o Docker machine promove grande facilidade de instalação e deploy em um ambiente cloud a partir de seus containers locais.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockermachine</category>
      <category>infraestrutura</category>
      <category>development</category>
    </item>
    <item>
      <title>Dockerhub and Registry Server</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Fri, 26 Jun 2020 22:22:52 +0000</pubDate>
      <link>https://dev.to/soutoigor/dockerhub-and-registry-server-c2m</link>
      <guid>https://dev.to/soutoigor/dockerhub-and-registry-server-c2m</guid>
      <description>&lt;p&gt;Dockerhub is the Docker's website for repositories of images, very similar to Github, where we create repositories of code, that other people can use. On Docker, we host our Docker images, private ou public, of enterprises or not. And then, other people can use that image that you've created.&lt;/p&gt;

&lt;p&gt;Accessing the &lt;a href="https://hub.docker.com/"&gt;Dockerhub's website&lt;/a&gt;, we can create our account and start using it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  LOGIN
&lt;/h3&gt;

&lt;p&gt;With the command &lt;code&gt;docker login&lt;/code&gt;, you can sign in your Dockerhub's account. If you want to sign in another Registry instead of Dockerhub, just put the URL after like &lt;code&gt;docker login &amp;lt;URL&amp;gt;&lt;/code&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  PUSH
&lt;/h2&gt;

&lt;p&gt;With the command &lt;code&gt;docker push&lt;/code&gt;, it's possible to push a local image to Dockerhub.&lt;/p&gt;

&lt;p&gt;The image's name must contain:&lt;/p&gt;

&lt;p&gt;Your Dockerhub's username + the name that you want to give for the image + the version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker push username/webserver:1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To change the docker's name, use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker tag username/serverweb:2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PULL
&lt;/h2&gt;

&lt;p&gt;To download the image from Dockerhub to the local machine, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker pull image-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The download will be made, and when finish, run using like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-ti&lt;/span&gt; webserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Registry
&lt;/h1&gt;

&lt;p&gt;A registry is like a "personal Dockerhub", for you or for your company. You can run in your local machine or any server, setting your own DNS, access control for users and etc.&lt;/p&gt;

&lt;p&gt;It's possible to add web interfaces, so you can easily view your registry, in Dockerhub has many examples of templates to install.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a local registry
&lt;/h2&gt;

&lt;p&gt;For building your local registry, in order not to need Dockerhub, either for your self or your company, we do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 5000:5000 &lt;span class="nt"&gt;--restart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;always &lt;span class="nt"&gt;--name&lt;/span&gt; registry registry:2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command is linking our port 5000 of host docker (local machine) and the image.&lt;/p&gt;

&lt;p&gt;We are telling Docker that if something happens to our container and he dies, it will be automatically restarted. We're giving our container the name "registry" and using the image "registry:2" from Dockerhub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pushing an image to the local registry
&lt;/h2&gt;

&lt;p&gt;For pushing images to the local registry, just renaming an image, replacing the username for the registry's URL, that in our case it would be like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker tag &amp;lt;image-id&amp;gt; &lt;span class="o"&gt;[&lt;/span&gt;localhost:5000/webserver:]&lt;span class="o"&gt;(&lt;/span&gt;http://localhost:5000/webserver:1.0&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it could be a server DNS etc.&lt;/p&gt;

&lt;p&gt;We use &lt;code&gt;docker push&lt;/code&gt; for pushing the image, as we did for pushing to Dockerhub, and &lt;code&gt;docker pull&lt;/code&gt; if we want to download an image from the registry.&lt;/p&gt;

&lt;p&gt;For verifying the images in your registry, run: (if is a DNS you would change it and either the port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl localhost:5000/v2/_catalog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Dockerhub is a very interesting alternative if you or a company wants to share images, whether public or private. And for those who want to have a more private alternative, with their own rules and settings, the Registry is a great alternative, being very customizable and having a lot of content available to assist those who want to create one.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockerhub</category>
      <category>registry</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>Dockerhub e Servidor Registry</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Fri, 26 Jun 2020 22:18:19 +0000</pubDate>
      <link>https://dev.to/soutoigor/dockerhub-e-servidor-registry-4flf</link>
      <guid>https://dev.to/soutoigor/dockerhub-e-servidor-registry-4flf</guid>
      <description>&lt;p&gt;Dockerhub é reposítorio de imagens do Docker, semelhante ao Github, onde criamos repositórios de códigos em que outras pessoas possam usar, no Dockerhub hospedamos nossas imagens do Docker, privadas ou públicas, de organizações ou não. E assim outras pessoas podem utilizar esta imagem que você criou.&lt;br&gt;
Acessando o site do &lt;a href="https://hub.docker.com/"&gt;Dockerhub&lt;/a&gt;, podemos criar nossa conta nele e já começar a usar.&lt;/p&gt;
&lt;h2&gt;
  
  
  Comandos para utilizar o Dockerhub localmente
&lt;/h2&gt;
&lt;h3&gt;
  
  
  LOGIN
&lt;/h3&gt;

&lt;p&gt;Com o comando &lt;code&gt;docker login&lt;/code&gt; podemos fazer login em nosso Dockerhub. Caso queira fazer login em outro registry sem ser o Dockerhub, basta colocar a url dele: &lt;code&gt;docker login &amp;lt;url&amp;gt;&lt;/code&gt; .&lt;/p&gt;
&lt;h3&gt;
  
  
  PUSH
&lt;/h3&gt;

&lt;p&gt;Com o comando &lt;code&gt;docker push&lt;/code&gt; é possível fazer o push de uma imagem local para o Dockerhub. O nome da imagem deve conter o seu nome de usuário do dockerhub + o nome que você quer dar a imagem + a versão. Ex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker push username/webserver:1.0 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Para mudar o nome da imagem, utilize o comando:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker tag username/image-name &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PULL
&lt;/h2&gt;

&lt;p&gt;Para baixar a imagem de volta para a máquina local, basta usar o comando:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker pull &amp;lt;nome-da-imagem&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Será feito o download da imagem. Finalizado o download, podemos rodar a imagem com:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-ti&lt;/span&gt; &amp;lt;nome-da-imagem&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Registry
&lt;/h1&gt;

&lt;p&gt;Um registry seria como um Dockerhub próprio, para você ou sua empresa. Você pode rodar em sua máquina local ou em algum servidor, configurando seu próprio DNS, controle de acesso de usuários e etc.&lt;/p&gt;

&lt;p&gt;É possível também adicionar interfaces web para que você possa visualizar seu Registry mais facilmente, no Dockerhub tem muitos exemplos.&lt;/p&gt;

&lt;h2&gt;
  
  
  Criando um registry local
&lt;/h2&gt;

&lt;p&gt;Para criar um Registry local, para não precisar do Dockerhub, seja para você mesmo ou para sua empresa, fazemos o seguinte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 5000:5000 &lt;span class="nt"&gt;--restart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;always &lt;span class="nt"&gt;--name&lt;/span&gt; registry registry:2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Este comando está linkando nossa porta 5000 do host docker (máquina local) e da imagem. Estamos dizendo também que caso aconteça algo com nosso container e ele caia, ele será automaticamente restartado. Estamos dando o nome do nosso container de "registry" e utilizando a imagem "registry:2" do Dockerhub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Subindo imagem para o registry local
&lt;/h2&gt;

&lt;p&gt;Para subir imagens para este registry local, apenas renomeamos uma imagem, substituindo o nome de usuário pela url do registry, que no nosso caso no momento fica: &lt;code&gt;docker tag &amp;lt;id-da-imagem&amp;gt; [localhost:5000/webserver:](http://localhost:5000/webserver:1.0&lt;/code&gt;)1.0` , mas poderia ser um dns que tivesse etc.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker push&lt;/code&gt; também para subir, assim como era para subir para o Dockehub, e &lt;code&gt;docker pull&lt;/code&gt; caso quisermos baixar uma imagem do registry.&lt;/p&gt;

&lt;p&gt;Para verificarmos quais imagens temos em nosso Registry, podemos rodar: (caso seja um DNS, seria apenas trocar a url, assim como a porta também).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
curl localhost:5000/v2/_catalog&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusão
&lt;/h2&gt;

&lt;p&gt;O Dockerhub é uma alternativa bem interessante caso você ou empresa queira compartilhar imagens, seja pública ou privado. E para quem deseja ter uma alternativa mais privada, com suas próprias regras e configurações, o Registry é uma ótima alternativa, sendo muito personalizável e tendo muito conteúdo disponível para auxiliar quem deseja fazer a criação de um.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockerhub</category>
      <category>registry</category>
      <category>infraestrutura</category>
    </item>
    <item>
      <title>Dockerfile: main commands and instructions</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Wed, 24 Jun 2020 23:39:53 +0000</pubDate>
      <link>https://dev.to/soutoigor/dockerfile-main-commands-and-instructions-2l2h</link>
      <guid>https://dev.to/soutoigor/dockerfile-main-commands-and-instructions-2l2h</guid>
      <description>&lt;p&gt;The Dockerfile what we use to create an image.&lt;/p&gt;

&lt;p&gt;It works like a recipe, we pass an image as base, commands and all the step by step.&lt;/p&gt;

&lt;p&gt;When building this Dockerfile, we create an image, and from this image, we create a container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Dockerfile commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  FROM
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; debian&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Must be the first command in a Dockerfile, with this command we set the image that will be used as base in our image.&lt;/p&gt;

&lt;h3&gt;
  
  
  ADD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ADD&lt;/span&gt;&lt;span class="s"&gt; opa.txt /directory/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To move a file into a container directory, it can be &lt;code&gt;.tar&lt;/code&gt; files.&lt;/p&gt;

&lt;h3&gt;
  
  
  CMD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["sh, "-c", "echo", "$HOME"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It defines a command to be executed when a container with this image initializes.&lt;/p&gt;

&lt;p&gt;There can be only one CMD instruction in a Dockerfile. If you add more than one, only the last will take effect.&lt;/p&gt;

&lt;p&gt;It can be overwritten when using if we pass another command in command line, like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; my-image /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  LABEL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;LABEL&lt;/span&gt;&lt;span class="s"&gt; Description="Bla bla bla giropops"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use it to set a container's description and keep it easy to manage all containers.&lt;/p&gt;

&lt;h3&gt;
  
  
  COPY
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; opa.txt /directory/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similar to ADD, but you can copy normal files and directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  ENTRYPOINT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["npm", "run", "dev"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's like &lt;code&gt;CMD&lt;/code&gt;, but this can not be overwritten, it will always execute, the container will run as an executable.&lt;/p&gt;

&lt;p&gt;When this command dies, the container dies too.&lt;/p&gt;

&lt;h3&gt;
  
  
  ENV
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; API_KEY="Igor Souto"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets environment variables to the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  EXPOSE
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets ports that container will expose, so that container will be accessible by this ports.&lt;/p&gt;

&lt;h3&gt;
  
  
  RUN
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install &lt;/span&gt;apache2 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Used to run commands in the container, generally used to install packages.&lt;br&gt;
Each RUN creates a new layer in our container, so we need to avoid creating too many RUN, to create fewer layers and don't let all too messy, after all, we only have read-write access in the last layer, so depending on what we want to do, we can't (e.g. apt-get clean in another RUN). &lt;br&gt;
You can read the Docker post &lt;a href="https://dev.to/soutoigor/docker-images-containers-and-its-main-commands-hgn"&gt;here&lt;/a&gt; to undestand more about image's layers.&lt;/p&gt;

&lt;h3&gt;
  
  
  USER
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; igor&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To define a user inside the container, the default is the ROOT user.&lt;/p&gt;

&lt;h3&gt;
  
  
  WORKDIR
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /mydir&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defines the directory of work. As the container gets executed, this is the directory that we will get inside when we access the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  VOLUME
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;VOLUME&lt;/span&gt;&lt;span class="s"&gt; /mydir&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creates a volume, a directory that will have a copy in our machine/host-docker.&lt;/p&gt;

&lt;p&gt;Changing something in that volume in our machine will reflect the container, and vice-versa.&lt;/p&gt;

&lt;h3&gt;
  
  
  MAINTAINER
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;MAINTAINER&lt;/span&gt;&lt;span class="s"&gt; Igor myemail@provider.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the container owner.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; first_image:1.0 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to build the image, we use the Docker build command. we pass the &lt;code&gt;-t&lt;/code&gt; parameter to name this image, a colon, and the version. And we use the ".", To say that our Dockerfile is at the same directory level. We don't point to the Dockerfile, but the directory it is in.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockerfile</category>
      <category>commands</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>Dockerfile: principais comandos e instruções</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Wed, 24 Jun 2020 23:29:48 +0000</pubDate>
      <link>https://dev.to/soutoigor/dockerfile-principais-comandos-e-instrucoes-2jpp</link>
      <guid>https://dev.to/soutoigor/dockerfile-principais-comandos-e-instrucoes-2jpp</guid>
      <description>&lt;p&gt;O Dockerfile é o meio que utilizamos para construir uma imagem.&lt;/p&gt;

&lt;p&gt;Ele funciona como uma receita, em que vamos passando uma imagem base, comandos e todo o passo a passo.&lt;/p&gt;

&lt;p&gt;Ao construir este Dockerfile, criamos nossa imagem, e a partir desta imagem, criamos nosso container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comandos mais úteis no Dockerfile
&lt;/h2&gt;

&lt;h2&gt;
  
  
  FROM
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; debian&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deve ser o primeiro comando de um Dockerfile, com ele configuramos qual a imagem que queremos utilizar como base na nossa imagem.&lt;/p&gt;

&lt;h2&gt;
  
  
  ADD
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ADD&lt;/span&gt;&lt;span class="s"&gt; opa.txt /diretorio/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Para mover um arquivo para dentro de um diretório do container, podendo ser arquivos &lt;code&gt;.tar&lt;/code&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  CMD
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["sh, "-c", "echo", "$HOME"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define um comando para ser executado quando um container com esta imagem inicializar.&lt;/p&gt;

&lt;p&gt;Pode haver apenas uma instrução CMD em um Dockerfile. Se você adicionar mais de um, apenas o último entrará em vigor.&lt;/p&gt;

&lt;p&gt;Ele pode ser sobrescrito se passarmos outro comando na linha de comando, como:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; minha-imagem /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  LABEL
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;LABEL&lt;/span&gt;&lt;span class="s"&gt; Description="Bla bla bla giropops"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Para adicionar uma descrição ao container e ficar mais fácil de gerenciar os containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  COPY
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; opa.txt /diretorio/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Semelhante ao ADD, porém vc pode copiar arquivos normais e diretórios.&lt;/p&gt;

&lt;h2&gt;
  
  
  ENTRYPOINT
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["npm", "run", "dev"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;É bem parecido com o &lt;code&gt;CMD&lt;/code&gt;, mas este não pode ser sobrescrito, ele sempre será executado e o container irá rodar como um executável.&lt;/p&gt;

&lt;p&gt;Quando este comando "morrer", o container morrerá também.&lt;/p&gt;

&lt;h2&gt;
  
  
  ENV
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; API_KEY="Igor Souto"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Para configurar variáveis de ambiente para o container.&lt;/p&gt;

&lt;h2&gt;
  
  
  EXPOSE
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configura portas que o container irá expor, e então o container será acessível por essas portas.&lt;/p&gt;

&lt;h2&gt;
  
  
  RUN
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install &lt;/span&gt;apache2 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usado para executar comandos no contêiner, geralmente usado para instalar pacotes.&lt;br&gt;
Cada RUN cria uma nova camada em nosso contêiner, portanto, precisamos evitar criar &lt;code&gt;RUN&lt;/code&gt;s demais, criar menos camadas e não deixar tudo muito confuso, afinal, só temos acesso read-write na última camada, dependendo sobre o que queremos fazer, não podemos (por exemplo, apt-get clean rodando em outro RUN).&lt;br&gt;
Para entender melhor como funcionam as camadas da imagem, acesse &lt;a href="https://dev.to/soutoigor/docker-imagens-containers-e-seus-principais-comandos-23p6"&gt;aqui&lt;/a&gt; o post sobre Docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  USER
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; igor&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Para definirmos qual será o usuário dentro do container, por padrão ele é o usuário ROOT.&lt;/p&gt;

&lt;h2&gt;
  
  
  WORKDIR
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /catota&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Para definirmos qual o diretório de trabalho. Assim que o container for executado, este diretório será o que iremos cair dentro ao acessar o container.&lt;/p&gt;

&lt;h2&gt;
  
  
  VOLUME
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;VOLUME&lt;/span&gt;&lt;span class="s"&gt; /diretorio&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Passamos o caminho em que o Docker irá criar um &lt;strong&gt;volume&lt;/strong&gt;, ou seja, um diretório que terá uma cópia em nossa máquina local e que se alterarmos algo neste diretório, será alterado dentro do container também e vice-versa.&lt;/p&gt;

&lt;h2&gt;
  
  
  MAINTAINER
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;MAINTAINER&lt;/span&gt;&lt;span class="s"&gt; Igor igor@email.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Passamos quem é o dono do container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build container
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; primeira_imagem:1.0 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Agora para buildar a imagem, usamos o comando &lt;code&gt;build&lt;/code&gt; do Docker. passamos o parametro &lt;code&gt;-t&lt;/code&gt;para nomear esta imagem, dois pontos e uma versão. E utilizamos o " . ", para dizer que nosso Dockerfile se encontra neste mesmo nível de diretório. Não apontamos o Dockerfile, e sim o diretório que ele se encontra.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockerfile</category>
      <category>infraestrutura</category>
      <category>comandos</category>
    </item>
    <item>
      <title>Docker: Imagens, Containers, e seus principais comandos</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Sat, 20 Jun 2020 16:17:01 +0000</pubDate>
      <link>https://dev.to/soutoigor/docker-imagens-containers-e-seus-principais-comandos-23p6</link>
      <guid>https://dev.to/soutoigor/docker-imagens-containers-e-seus-principais-comandos-23p6</guid>
      <description>&lt;p&gt;O Docker veio para facilitar a criação e gerenciamento de ambientes, para usos perssoais, de empresas e comunidades open-source. Rodando apenas um comando, agora podemos ter o ambiente inteiro em que um projeto foi construido, com suas versões e aplicações instaladas e rodando.&lt;/p&gt;

&lt;p&gt;E agora a frase "Mas na minha máquina funciona" já não é mais necessária, porque sempre teremos o mesmo ambiente, independente de onde a aplicação esteja rodando. :D&lt;/p&gt;

&lt;p&gt;Vamos ver um pouco de como o Docker funciona e o que podemos fazer com ele!&lt;/p&gt;

&lt;h2&gt;
  
  
  Container
&lt;/h2&gt;

&lt;p&gt;Um container é onde as dependências serão instaladas, as aplicações e tudo para nosso projeto poder rodar. Ele utiliza de imagens (como pequenos SOs como base) para rodar a aplicação. Quando a aplicação precisar utilizar o Kernel, ela não utilizará o Kernel do container, porque ele não possui um. Ele utilizará o Kernel do &lt;strong&gt;host docker&lt;/strong&gt; (máquina física).&lt;/p&gt;

&lt;p&gt;Este único Kernel irá gerenciar todos os container em execução.&lt;/p&gt;

&lt;p&gt;Um container &lt;strong&gt;não&lt;/strong&gt; é uma VM, como muitas pessoas dizem. Em uma VM todo o SO é virtualizado, um SO completo com um kernel e muitas camadas até a aplicação, consumindo muito mais recursos.&lt;/p&gt;

&lt;p&gt;Um container é pequeno, a aplicação fica muito mais perto da infraestrutura e SO.&lt;/p&gt;

&lt;p&gt;Uma VM emula uma &lt;em&gt;máquina&lt;/em&gt; , um container emula uma &lt;em&gt;aplicação.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_j5SFaM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ivn5l5ocva3olxg1emc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_j5SFaM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ivn5l5ocva3olxg1emc6.png" alt="Container and VM structure" width="880" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Um container também é portável, você facilmente consegue pegar os binários que o Docker cria e passar para uma outra máquina/servidor, funcionará perfeitamente.&lt;/p&gt;

&lt;h2&gt;
  
  
  Imagens
&lt;/h2&gt;

&lt;p&gt;Uma imagem é como se fôsse um container em um ponto no tempo ou como um container parado.&lt;/p&gt;

&lt;p&gt;Quando você constrói um container, usa imagens que foram um container e compartilhado no &lt;strong&gt;Dockerhub&lt;/strong&gt; (ou você pode construir a sua própria do zero).&lt;/p&gt;

&lt;p&gt;Se você constrói um container, para ele e compartilha, outras pessoas poderão usar ele como uma imagem dentro de seus containers.&lt;/p&gt;

&lt;p&gt;Usando o conceito de POO, é como se a imagem fosse uma classe e o container uma instância desta imagem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Camadas
&lt;/h3&gt;

&lt;p&gt;O &lt;strong&gt;file system&lt;/strong&gt; do Docker trabalha com camadas.&lt;/p&gt;

&lt;p&gt;Quando se está construindo uma imagem, cada passo cria uma camada, e todas as camadas são &lt;strong&gt;read-only,&lt;/strong&gt; exceto a última, que será sempre &lt;strong&gt;read-write.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XVs5Go_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/44yb46wjcd3o9vxomz7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XVs5Go_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/44yb46wjcd3o9vxomz7n.png" alt="Image Layers" width="220" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vih5uTs3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4n7ceozlbadvf7ak3m7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vih5uTs3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4n7ceozlbadvf7ak3m7t.png" alt="Image layers with an application" width="686" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Copy on Write
&lt;/h3&gt;

&lt;p&gt;Quando é preciso modificar uma camada read-only, esta camada será copiada para a camada &lt;strong&gt;read-write&lt;/strong&gt; e então poderá ser modificada.&lt;/p&gt;

&lt;p&gt;Esta ação é chamada de &lt;strong&gt;Copy on Write.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;É como se fosse um livro, que você pode ler, mas quando você for alterar uma página, no momento em que você encosta a caneta na folha está folha é copiada e você modifica esta folha copiada, que criará uma nova folha, preservando a folha antiga.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comando da CLI do Docker
&lt;/h2&gt;

&lt;h3&gt;
  
  
  RUN
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;É o comando que inicializa um container, passando o nome da imagem que o container irá utilizar.&lt;/p&gt;

&lt;p&gt;Se o Docker não encontrar esta imagem localmente, ele autmaticamente ira tentar encontrar esta imagem no &lt;strong&gt;Dockerhub&lt;/strong&gt; irá começar a fazer seu download e em seguida rodar o container.&lt;/p&gt;

&lt;h3&gt;
  
  
  PS
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;Lista todos os containers em execução.&lt;/p&gt;

&lt;p&gt;Passando o parâmetro &lt;code&gt;-a&lt;/code&gt; depois de &lt;code&gt;ps&lt;/code&gt; irá listar todos os containers, incluindo os que estão parados.&lt;/p&gt;

&lt;h3&gt;
  
  
  IMAGES
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vai listar todas as imagens que estão na sua máquina.&lt;/p&gt;

&lt;h3&gt;
  
  
  CREATE
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker create ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Irá criar um container, mas não irá executá-lo.&lt;/p&gt;

&lt;h3&gt;
  
  
  STOP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Para um container.&lt;/p&gt;

&lt;h3&gt;
  
  
  START
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker start container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inicia um container parado.&lt;/p&gt;

&lt;h3&gt;
  
  
  STATS
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;Mostra os status que um container está utilizando, como memória, rede e CPU.&lt;/p&gt;

&lt;h3&gt;
  
  
  RM
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm &lt;/span&gt;container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove um container, se um container estiver em execução, use o parâmetro  &lt;code&gt;-f&lt;/code&gt; para forçar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parâmetros importantes do comando RUN
&lt;/h2&gt;

&lt;h2&gt;
  
  
  -ti
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-ti&lt;/span&gt; image-name /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;O &lt;em&gt;t&lt;/em&gt; é de &lt;em&gt;terminal&lt;/em&gt;, e &lt;em&gt;i&lt;/em&gt; de &lt;em&gt;interativo&lt;/em&gt;, então estamos dizendo que queremos utilizar o terminar e que seja interativo para utilizar o container.&lt;/p&gt;

&lt;h3&gt;
  
  
  -d
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nt"&gt;-d&lt;/span&gt; image-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;É para todar um container em modo daemon (em background).&lt;/p&gt;

&lt;p&gt;É útil para containers "data-only", que não precisará de interação.&lt;/p&gt;

&lt;h3&gt;
  
  
  ATTACH
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker attach container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retorna para um container fechado (mas não parado).&lt;/p&gt;

&lt;h2&gt;
  
  
  Commandos para o Bash
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CTRL + D
&lt;/h3&gt;

&lt;p&gt;Vai fechar o container, matando o bash, e se o bash for o job principal do container, irá matar o container também.&lt;/p&gt;

&lt;h3&gt;
  
  
  CTRL + P + Q
&lt;/h3&gt;

&lt;p&gt;Irá sair do container sem matar ele, apenas fechado. Você pode voltar para este container utilizando o comando&lt;code&gt;attach&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bônus: liberando memória
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;docker ps &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; docker rmi &lt;span class="si"&gt;$(&lt;/span&gt;docker images &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker system prune &lt;span class="nt"&gt;--volumes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusão
&lt;/h2&gt;

&lt;p&gt;O Docker veio para ajudar muito em nossas vidas, com apenas algumas configurações, nós podemos desenvolver um grande ambiente, em que qualquer um com Docker poderá utilizar também.&lt;/p&gt;

</description>
      <category>container</category>
      <category>imagens</category>
      <category>docker</category>
      <category>ambientes</category>
    </item>
    <item>
      <title>Docker: Images, Containers, and its main commands</title>
      <dc:creator>Igor Souto</dc:creator>
      <pubDate>Sat, 20 Jun 2020 16:02:07 +0000</pubDate>
      <link>https://dev.to/soutoigor/docker-images-containers-and-its-main-commands-hgn</link>
      <guid>https://dev.to/soutoigor/docker-images-containers-and-its-main-commands-hgn</guid>
      <description>&lt;p&gt;Docker came to facilitate the creation and management of environments, for personal users, enterprises, and open-source communities.&lt;br&gt;
Running just a command, we can now have the entire environment that the project was built with, with its versions and applications installed and running, easy setup.&lt;/p&gt;

&lt;p&gt;And the phrase "but it works on my machine" is not necessary anymore, because we always have the same environment, whatever we are running the application. :D&lt;/p&gt;

&lt;p&gt;Let's see a little bit of how Docker works and what we can do with it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Container
&lt;/h2&gt;

&lt;p&gt;A container is where you will install your dependencies, application, and everything to your project to start running. It will use the container images (like little OS as a base) to run the application, and when it needs to use the Kernel, it will not use the container's kernel, because it does not have one. It will use the &lt;strong&gt;host docker&lt;/strong&gt;'s Kernel (the physical machine). &lt;/p&gt;

&lt;p&gt;This Kernel will manage all the containers running.&lt;/p&gt;

&lt;p&gt;A container is not a VM like most people say. A VM you have to virtualize all the OS, it's big, a complete OS with a kernel and many layers until the application, consuming much more resources.&lt;br&gt;
A container is small, the application is closer to the infrastructure and OS.&lt;/p&gt;

&lt;p&gt;A VM emulates a &lt;em&gt;machine&lt;/em&gt;, the container emulates an &lt;em&gt;application&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_j5SFaM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ivn5l5ocva3olxg1emc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_j5SFaM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ivn5l5ocva3olxg1emc6.png" alt="Container and VM structure" width="880" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's portable too, you can easily get the binaries that Docker creates for the container and put in another server/machine, it will work like a charm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Images
&lt;/h2&gt;

&lt;p&gt;A Docker image is like a Docker container in a point at the time, or like stopped docker container.&lt;/p&gt;

&lt;p&gt;When you build a container, you use images that are a container that was created and shared in Dockerhub (or you can build yours from scratch).&lt;/p&gt;

&lt;p&gt;If you build a container, stop and share it, other people can use it inside their container as an image.&lt;/p&gt;

&lt;p&gt;Using the OOP concept, It's like the image is a Class and a container is an instance of that image.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layers
&lt;/h3&gt;

&lt;p&gt;The Docker's file system works with layers.&lt;/p&gt;

&lt;p&gt;When you're building an image, each step creates a layer, and all layers are &lt;strong&gt;read-only,&lt;/strong&gt; except the last layer that is &lt;strong&gt;Read-write.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XVs5Go_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/44yb46wjcd3o9vxomz7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XVs5Go_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/44yb46wjcd3o9vxomz7n.png" alt="Image Layers" width="220" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vih5uTs3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4n7ceozlbadvf7ak3m7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vih5uTs3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4n7ceozlbadvf7ak3m7t.png" alt="Image layers with an application" width="686" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Copy on Write
&lt;/h3&gt;

&lt;p&gt;When you need to modify a read-only layer, this layer will be copied to the &lt;strong&gt;read-write&lt;/strong&gt; layer and then it can be modified.&lt;/p&gt;

&lt;p&gt;This action is called &lt;strong&gt;Copy on Write.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is like a book, that you can read, but when you change a sheet, the moment that you touch the pen, that sheet is copied and you modify that copied sheet, creating a new sheet, preserving the old one.&lt;/p&gt;

&lt;h2&gt;
  
  
  CLI Commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  RUN
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Is the command the initializes a container, passing the image's name that the container will use.&lt;/p&gt;

&lt;p&gt;If Docker is unable to find that image locally, it will automatically try to find that image in Dockerhub and start downloading and running.&lt;/p&gt;

&lt;h3&gt;
  
  
  PS
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;List the containers in execution.&lt;/p&gt;

&lt;p&gt;Passing the parameter &lt;code&gt;-a&lt;/code&gt; after  &lt;code&gt;ps&lt;/code&gt; will list all containers, including the stopped ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  IMAGES
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We Will list all images in your machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  CREATE
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker create ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It creates a container but not execute it.&lt;/p&gt;

&lt;h3&gt;
  
  
  STOP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stops the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  START
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker start container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It starts a stopped container.&lt;/p&gt;

&lt;h3&gt;
  
  
  STATS
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;Show the stats like memory, net, and CPU of a container.&lt;/p&gt;

&lt;h3&gt;
  
  
  RM
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm &lt;/span&gt;container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes a container, if the container is running, use the parameter &lt;code&gt;-f&lt;/code&gt; to force it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important parameters for command Run
&lt;/h2&gt;

&lt;h2&gt;
  
  
  -ti
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-ti&lt;/span&gt; image-name /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;t&lt;/em&gt; is &lt;em&gt;terminal&lt;/em&gt;, and &lt;em&gt;i&lt;/em&gt; is &lt;em&gt;interactive&lt;/em&gt;, so we are telling that we can want a terminal and it will be interactive to use the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  -d
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nt"&gt;-d&lt;/span&gt; image-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is for running the container in daemon mode (in the background).&lt;/p&gt;

&lt;p&gt;It's useful for "data-only" containers, that will not need interaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  ATTACH
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker attach container-id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Return to a closed (but not stopped) container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bash commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CTRL + D
&lt;/h3&gt;

&lt;p&gt;Will exit the container "killing" the bash, and if the bash is the principal job of the container, the container will be killed.&lt;/p&gt;

&lt;h3&gt;
  
  
  CTRL + P + Q
&lt;/h3&gt;

&lt;p&gt;Will exit the container without "killing" it, just closing. You can go back to this container using the &lt;code&gt;attach&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Freeing memory
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;docker ps &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; docker rmi &lt;span class="si"&gt;$(&lt;/span&gt;docker images &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker system prune &lt;span class="nt"&gt;--volumes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Docker came to help a lot with our lives, with just some settings, we can develop a huge environment that anyone with Docker can easily use too.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>container</category>
      <category>images</category>
      <category>environments</category>
    </item>
  </channel>
</rss>
