{"id":1450,"date":"2021-08-04T07:51:00","date_gmt":"2021-08-04T10:51:00","guid":{"rendered":"https:\/\/www.erudio.com.br\/blog\/?p=1450"},"modified":"2022-12-21T15:24:50","modified_gmt":"2022-12-21T18:24:50","slug":"os-principais-comandos-para-usados-na-gestao-de-docker-images","status":"publish","type":"post","link":"https:\/\/www.erudio.com.br\/blog\/os-principais-comandos-para-usados-na-gestao-de-docker-images\/","title":{"rendered":"Os Principais Comandos para Usados na Gest\u00e3o de Docker Images"},"content":{"rendered":"<p>Fala pessoal beleza!<br \/>\nNesse post a gente vai continuar conhecendo os principais comandos Docker iniciado no post anterior em que conhecemos os <a href=\"https:\/\/www.erudio.com.br\/blog\/os-principais-comandos-para-usados-na-gestao-de-conteineres\/\"><strong>Principais Comandos para Usados na Gest\u00e3o de Docker Images<\/strong><\/a>. Agora vamos focar nos comandos usados para gerenciar Docker Images.<\/p>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p style=\"text-align: left; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">pull\u00a0<\/span><span style=\"line-height: 107%; color: #658b00;\">REGISTRY\/<\/span><span style=\"color: #c00000;\">IMAGE:TAG<\/span> <span style=\"font-family: Wingdings;\">\u00e0<\/span> baixa uma <em>Docker image<\/em> do Docker Hub.<\/p>\n<ol style=\"list-style-type: circle;\">\n<li>Para imagens oficiais n\u00e3o precisamos passar o <span style=\"line-height: 107%; font-size: 16px;\">REGISTRY\/<\/span><span style=\"color: #c00000;\">\u00a0<\/span>j\u00e1 para \u00e0s nossas <em>Docker images<\/em> precisamos passar o nosso usu\u00e1rio no Docker Hub ou no registry em uso;<\/li>\n<li>O comando\u00a0<span style=\"color: #ed7d31;\">docker\u00a0<\/span><span style=\"line-height: 107%; color: #032f62; background: white; font-size: 16px;\">run<\/span><span style=\"color: #ed7d31;\">\u00a0<\/span>faz um<span style=\"color: #ed7d31;\">\u00a0docker<\/span> <span style=\"line-height: 107%; color: #032f62; font-size: 12.0pt; background: white;\">pull\u00a0<\/span><span style=\"line-height: 107%; background: white; font-size: 16px;\">de\u00a0<\/span>modo totalemnete transparente se ele n\u00e3o encontrar a imagem necess\u00e1ria \u00e0 inicializa\u00e7\u00e3o do cont\u00eainer no Host.<\/li>\n<\/ol>\n<p style=\"text-align: left; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">image ls\u00a0<\/span><span style=\"font-family: Wingdings;\">\u00e0<\/span> Lista todas as <em>Docker images<\/em>;<\/p>\n<ol style=\"list-style-type: circle;\">\n<li><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Nas vers\u00f5es mais antigas do Docker a sintaxe desse comando era mais simples, apenas\u00a0<\/span><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62;\">images<\/span>;<\/li>\n<li><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Hoje podemos usar as duas sintaxes.<\/span><\/li>\n<\/ol>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">image rm\u00a0<\/span><span style=\"color: #c00000;\">IMAGE_ID<\/span> <span style=\"font-family: Wingdings;\">\u00e0<\/span> Remove uma <em>Docker image<\/em>;<\/p>\n<ol style=\"list-style-type: circle;\">\n<li><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Nas vers\u00f5es mais antigas do Docker a sintaxe desse comando era mais simples, apenas\u00a0<\/span><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62;\">rmi\u00a0<\/span><span style=\"color: #c00000;\">IMAGE_ID<\/span>;<\/li>\n<li><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Hoje podemos usar as duas sintaxes.<\/span><\/li>\n<li>Caso algum cont\u00eainer esteja usando a <em>Docker image<\/em> ela n\u00e3o ser\u00e1 removida. Podemos adicionar o par\u00e2metro <span style=\"color: #c00000;\">-f\u00a0<\/span>para for\u00e7ar a remo\u00e7\u00e3o mesmo se estiver em execu\u00e7\u00e3o;\n<ul style=\"list-style-type: square;\">\n<li>Caso a remo\u00e7\u00e3o seja for\u00e7ada qualquer cont\u00eainer relacionado tamb\u00e9m ser\u00e1 removido.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p style=\"text-align: left; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">image prune<\/span> <span style=\"font-family: Wingdings;\">\u00e0<\/span> Remove todas as\u00a0<em>Docker images\u00a0<\/em>que n\u00e3o est\u00e3o em uso;<\/p>\n<ol style=\"list-style-type: circle;\">\n<li>N\u00e3o existia um comando equivalente em vers\u00f5es anteriores do Docker e normalmente improvis\u00e1vamos com o comando:\n<ul style=\"list-style-type: square;\">\n<li><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62;\">rmi $(<\/span><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; font-size: 12.0pt; background: white;\">images<\/span><span style=\"color: #c00000;\">\u00a0-q<\/span><span style=\"line-height: 107%; color: #032f62;\">)<\/span> <span style=\"color: #c00000;\">-f\u00a0<\/span><span style=\"font-family: Wingdings;\">\u00e0<\/span> A parte dentro dos par\u00eantesis lista todas as imagens. E a parte externa remove todas as imagens retornadas na lista interna. O <span style=\"color: #c00000;\">-f<\/span> pode ser usado, de forma opcional, para for\u00e7ar a remo\u00e7\u00e3o, mesmo que a imagem esteja sendo usada em algum cont\u00eainer em execu\u00e7\u00e3o.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p style=\"text-align: left; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p style=\"text-align: left; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">image tag<\/span> <span style=\"line-height: 107%; color: #658b00;\">SRC_IMAGE:TAG<\/span><\/p>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm .0001pt 36.0pt;\"><span style=\"color: #c00000;\">DOCKER_HUB_USER\/IMAGE_NAME:TAG<\/span> <span style=\"font-family: Wingdings;\">\u00e0<\/span> Cria uma tag a partir de uma <em>Docker image<\/em> existente.<\/p>\n<div style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<ol style=\"margin-bottom: 0cm; list-style-type: circle;\">\n<li style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Nas vers\u00f5es mais antigas do Docker a sintaxe desse comando era mais simples, apenas\u00a0<\/span><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62;\">tag<\/span> <span style=\"line-height: 107%; color: #658b00;\">SRC_IMAGE:TAG<\/span><\/li>\n<\/ol>\n<\/div>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm .0001pt 72.0pt;\"><span style=\"color: #c00000;\">DOCKER_HUB_USER\/IMAGE_NAME:TAG<\/span>;<\/p>\n<div style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<ol style=\"margin-bottom: 0cm; list-style-type: circle;\">\n<li style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Hoje podemos usar as duas sintaxes pessoalmente eu prefiro a segunda op\u00e7\u00e3o.<\/span><\/li>\n<\/ol>\n<\/div>\n<p style=\"text-align: left; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 18.0pt;\">\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">login docker.io<\/span> <span style=\"font-family: Wingdings;\">\u00e0<\/span> Autentica no DockerHub via console.<\/p>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 36.0pt;\">\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"color: #ed7d31;\">docker<\/span><span style=\"line-height: 107%; color: #032f62; background: white;\">\u00a0image<\/span> <span style=\"line-height: 107%; color: #032f62; background: white;\">push<\/span> <span style=\"color: #c00000;\">DOCKER_HUB_USER\/IMAGE_NAME:TAG<\/span> <span style=\"font-family: Wingdings;\">\u00e0<\/span> Envia uma imagem para o DockerHub;<\/p>\n<div style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<ol style=\"margin-bottom: 0cm; list-style-type: circle;\">\n<li style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\"><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Nas vers\u00f5es mais antigas do Docker a sintaxe desse comando era mais simples, apenas\u00a0<\/span><span style=\"color: #ed7d31;\">docker<\/span><span style=\"line-height: 107%; color: #032f62;\">\u00a0push<\/span><\/li>\n<\/ol>\n<\/div>\n<p style=\"text-align: justify; text-indent: 0cm; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm .0001pt 72.0pt;\"><span style=\"color: #c00000;\">DOCKER_HUB_USER\/IMAGE_NAME:TAG<\/span>;<\/p>\n<ol style=\"list-style-type: circle;\">\n<li><span style=\"line-height: 107%; color: black; font-family: 'Segoe UI'; font-size: 16px;\">Hoje podemos usar as duas sintaxes pessoalmente eu prefiro a segunda op\u00e7\u00e3o;<\/span><\/li>\n<li>Se ocorrer um erro de autentica\u00e7\u00e3o ao executar o comando <span style=\"color: #ed7d31;\">docker<\/span> <span style=\"line-height: 107%; color: #032f62;\">login docker.io<\/span><span style=\";font-size: 12.0pt; ;background: white;\">\u00a0voc\u00ea n\u00e3o conseguir\u00e1 executar esse comando;<\/span><\/li>\n<li><span style=\"line-height: 107%; background: white; font-size: 16px;\">Firewalls, VPN\u2019s e antiv\u00edrus podem te pregar boas pe\u00e7as nessa etapa.<\/span><\/li>\n<\/ol>\n<p style=\"text-align: justify; text-indent: 35.4pt; line-height: 107%; font-size: 16px; font-family: Open Sans; margin: 0cm 0cm 8.0pt 0cm;\">\n<p>E <strong><em>se voc\u00ea quer se tornar<\/em><\/strong> um verdadeiro <em><strong>ninja Docker<\/strong><\/em> e conhecer mais sobre <strong>Docker<\/strong> e <strong>Docker Compose<\/strong> eu recomendo <a href=\"https:\/\/pub.erudio.com.br\/guia-docker\"><strong><em>baixar o meu e-Book gratuito<\/em><\/strong> <strong>Docker um guia R\u00e1pido<\/strong><\/a> e dar uma conferida numa playlist sobre o tema <strong><a href=\"https:\/\/www.youtube.com\/c\/ErudioTraining\/videos\">no meu canal no Youtube<\/a><\/strong>.<\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/guia-docker\" target=\"_blank\" rel=\"noopener\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.erudio.com.br\/blog\/wp-content\/uploads\/2021\/06\/banner_inscricao_model3.png\" alt=\"Baixe o Guia Docker gr\u00e1tis\" \/><br \/>\n<\/a><\/p>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\" title=\"Docker para Iniciantes: Minicurso Gratuito Completo!\" src=\"https:\/\/www.youtube.com\/embed\/videoseries?list=PL18bbNo7xuh84zAeNjNejyzd1GASt8Q9x\" width=\"648\" height=\"365\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><\/div>\n<\/figure>\n<p>Bom por esse post \u00e9 isso a gente se v\u00ea no pr\u00f3ximo post!!!<\/p>\n<h2>Treinamentos relacionados com este post<\/h2>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_docker\" target=\"_blank\" rel=\"noopener\"><br \/>\n<img decoding=\"async\" style=\"max-width: 100%;\" title=\"Docker do 0 \u00e0 Maestria: Cont\u00eaineres Desmistificados mais 3 B\u00d4NUS\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/09-docker.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_docker_para_aws\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"Docker para Amazon AWS Implante Apps Java e .NET com Travis CI\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/10-docker-to-aws.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_rest_spring_java\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"REST API's RESTFul do 0 \u00e0  AWS com Spring Boot 3, Java e Docker\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/07-rest-spring-java.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_rest_asp_net\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"REST API's RESTFul do 0 \u00e0 Azure com ASP.NET Core 5 e Docker\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/01-rest-asp.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_rest_spring_kotlin\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"REST API's RESTFul do 0 \u00e0 AWS com Spring Boot 3, Kotlin e Docker\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/18-rest-spring-kotlin.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_microservices_java\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"Microservices do 0 com Spring Cloud, Spring Boot e Docker\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/14-microservices-java.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_microservices-dotnet\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"Arquitetura de Microsservi\u00e7os do 0 com ASP.NET, .NET 6 e C#\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/15-microservices-dotnet.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_ms_kotlin\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"Microsservi\u00e7os do 0 com Spring Cloud, Kotlin e Docker\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/22-ms-kotlin.png\" \/><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/pub.erudio.com.br\/kr\/blog_kotlin\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"Kotlin para DEVs Java: Aprenda a Linguagem Padr\u00e3o do Android\" src=\"https:\/\/raw.githubusercontent.com\/leandrocgsi\/blog-images\/main\/20-kotlin.png\" \/><br \/>\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fala pessoal beleza! Nesse post a gente vai continuar conhecendo os principais comandos Docker iniciado no post anterior em que conhecemos os Principais Comandos para Usados na Gest\u00e3o de Docker Images. Agora vamos focar nos comandos usados para gerenciar Docker Images. docker pull\u00a0REGISTRY\/IMAGE:TAG \u00e0 baixa uma Docker image do Docker Hub. Para imagens oficiais n\u00e3o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1231,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[268,261,27,260,262,1],"tags":[269,151,263,264],"_links":{"self":[{"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/posts\/1450"}],"collection":[{"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/comments?post=1450"}],"version-history":[{"count":3,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/posts\/1450\/revisions"}],"predecessor-version":[{"id":1546,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/posts\/1450\/revisions\/1546"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/media\/1231"}],"wp:attachment":[{"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/media?parent=1450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/categories?post=1450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.erudio.com.br\/blog\/wp-json\/wp\/v2\/tags?post=1450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}